Skip to content

Commit

Permalink
Merge pull request #19 from erikjanwestendorp/fix-some-build-warnings
Browse files Browse the repository at this point in the history
Small improvements
  • Loading branch information
Jeavon authored Jan 17, 2023
2 parents b5a394a + ca03259 commit 6f6408e
Show file tree
Hide file tree
Showing 27 changed files with 58 additions and 94 deletions.
7 changes: 1 addition & 6 deletions Umbraco.Docs.Samples.Web/Controllers/Api/PeopleController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.PublishedModels;
using Umbraco.Extensions;

namespace Umbraco.Docs.Samples.Web.Controllers.Api;

Expand Down
1 change: 0 additions & 1 deletion Umbraco.Docs.Samples.Web/Controllers/DefaultController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Controllers;
Expand Down
5 changes: 1 addition & 4 deletions Umbraco.Docs.Samples.Web/Controllers/PersonController.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core.Cache;
Expand Down
2 changes: 0 additions & 2 deletions Umbraco.Docs.Samples.Web/CustomIndexing/ExamineComposer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Examine;
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Infrastructure.Examine;

namespace Umbraco.Docs.Samples.Web.CustomIndexing
Expand Down
2 changes: 0 additions & 2 deletions Umbraco.Docs.Samples.Web/CustomIndexing/ProductIndex.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Examine.Lucene;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Examine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Examine;
using Examine;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.Examine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Examine;
using Examine;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Infrastructure.Examine;

Expand Down
1 change: 0 additions & 1 deletion Umbraco.Docs.Samples.Web/Dashboards/MyDashboardComposer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.DependencyInjection;

namespace Umbraco.Docs.Samples.Web.Dashboards
{
Expand Down
1 change: 0 additions & 1 deletion Umbraco.Docs.Samples.Web/Dashboards/RemoveDashboard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Dashboards;
using Umbraco.Cms.Core.DependencyInjection;

namespace Umbraco.Docs.Samples.Web.Dashboards
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;

namespace Umbraco.Docs.Samples.Web.Notifications
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;

namespace Umbraco.Docs.Samples.Web.Notifications
Expand Down
3 changes: 1 addition & 2 deletions Umbraco.Docs.Samples.Web/Notifications/CultureSavedCheck.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;

namespace Umbraco.Docs.Samples.Web.Notifications
Expand Down
3 changes: 1 addition & 2 deletions Umbraco.Docs.Samples.Web/Notifications/CultureSavingCheck.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;

namespace Umbraco.Docs.Samples.Web.Notifications
Expand Down
14 changes: 9 additions & 5 deletions Umbraco.Docs.Samples.Web/Notifications/DontShout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ public void Handle(ContentPublishingNotification notification)
if (contentItem.ContentType.Alias.Equals("blogpost"))
{
var blogPostTitle = contentItem.GetValue<string>("pageTitle");
if (blogPostTitle.Equals(blogPostTitle.ToUpper()))

if (!string.IsNullOrWhiteSpace(blogPostTitle))
{
notification.Cancel = true;
notification.CancelOperation(new EventMessage("Corporate style guideline infringement",
"Don't put the blog post title in upper case, no need to shout! Publishing was cancelled",
EventMessageType.Error));
if (blogPostTitle.Equals(blogPostTitle.ToUpper()))
{
notification.Cancel = true;
notification.CancelOperation(new EventMessage("Corporate style guideline infringement",
"Don't put the blog post title in upper case, no need to shout! Publishing was cancelled",
EventMessageType.Error));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Linq;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Extensions;

namespace Umbraco.Docs.Samples.Web.Notifications
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using System.Web;
using System.Web;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Web.Common.PublishedModels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.PropertyEditors;
Expand All @@ -9,16 +7,15 @@
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.PublishedModels;
using Umbraco.Extensions;

namespace Umbraco.Docs.Samples.Web.Property_Editors_Add_Values
{
public class CreateImageCropperValuesController : UmbracoApiController
{
private IContentService _contentService;
private IMediaService _mediaService;
private MediaUrlGeneratorCollection _mediaUrlGeneratorCollection;
private IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IContentService _contentService;
private readonly IMediaService _mediaService;
private readonly MediaUrlGeneratorCollection _mediaUrlGeneratorCollection;
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;


public CreateImageCropperValuesController(IContentService contentService, IMediaService mediaService, MediaUrlGeneratorCollection mediaUrlGeneratorCollection, IPublishedSnapshotAccessor publishedSnapshotAccessor)
Expand Down Expand Up @@ -51,10 +48,19 @@ public ActionResult<string> CreateImageCropperValues()
// Serialize the image cropper value
var cropperValue = JsonConvert.SerializeObject(cropper);

// Get the alias of the 'cropper' property
var testCropperAlias = Product.GetModelPropertyType(_publishedSnapshotAccessor, x => x.TestCropper)?.Alias;

// Set the value of the property with alias 'cropper'
content.SetValue("testCropper", cropperValue, "en-US");
if (content != null && !string.IsNullOrWhiteSpace(testCropperAlias))
{
// Set the value of the cropper
content.SetValue("testCropper", cropperValue, "en-US");

content.SetValue(Product.GetModelPropertyType(_publishedSnapshotAccessor,x => x.TestCropper).Alias, cropperValue, "en-US");
// Set the value of the cropper using the 'testCropperAlias' variable
content.SetValue(testCropperAlias, cropperValue, "en-US");
}


return _contentService.Save(content).Success.ToString();
}
Expand All @@ -67,10 +73,21 @@ internal Dictionary<string, string> GetCropUrls(IPublishedContent image)
if (image.HasValue("umbracoFile"))
{
var imageCropper = image.Value<ImageCropperValue>("umbracoFile");
foreach (var crop in imageCropper.Crops)

if (imageCropper != null && imageCropper.Crops != null)
{
//Get the cropped URL and add it to the dictionary that I will return
cropUrls.Add(crop.Alias, image.GetCropUrl(crop.Alias));
foreach (var crop in imageCropper.Crops)
{
//Get the cropped URL and add it to the dictionary that I will return
if (!string.IsNullOrWhiteSpace(crop.Alias))
{
var cropUrl = image.GetCropUrl(crop.Alias);
if (!string.IsNullOrEmpty(cropUrl))
{
cropUrls.Add(crop.Alias, cropUrl);
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Logging;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Sync;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Docs.Samples.Web.Notifications;
using Umbraco.Docs.Samples.Web.Notifications;

namespace Umbraco.Docs.Samples.Web.RecurringHostedService
{
Expand Down
5 changes: 1 addition & 4 deletions Umbraco.Docs.Samples.Web/Services/SearchService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using Examine;
using Examine;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Infrastructure.Examine;
using Umbraco.Extensions;

namespace Umbraco.Docs.Samples.Web.Services
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Trees;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Actions;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models.Trees;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Trees;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Extensions;

// https://our.umbraco.com/Documentation/Extending/Section-Trees/trees

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Cms.Web.BackOffice.Trees;

// https://our.umbraco.com/Documentation/Extending/Section-Trees/Searchable-Trees/#example

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System.IO;
using System;
using System.Collections.Generic;

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Http.Headers;
using Microsoft.Net.Http.Headers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Options;

namespace Umbraco.Docs.Samples.Web.Tutorials
{
Expand Down

0 comments on commit 6f6408e

Please sign in to comment.