feat(AddBanner) , feat(AddCatelog) , feat(AddPersonalizationPage)
parent
e9764c6cd4
commit
5524cb4e43
|
@ -1,4 +1,7 @@
|
|||
namespace Netina.Api.Controllers;
|
||||
using Netina.Domain.Enums;
|
||||
using Netina.Domain.MartenEntities.Settings;
|
||||
|
||||
namespace Netina.Api.Controllers;
|
||||
|
||||
public class WebSiteController : ICarterModule
|
||||
{
|
||||
|
@ -9,8 +12,38 @@ public class WebSiteController : ICarterModule
|
|||
group.MapGet("/navbar", GetNavBarItemsAsync)
|
||||
.WithDisplayName("Get NavBar Items")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("/catelog", GetCatalogAsync)
|
||||
.WithDisplayName("Get Catalog Items")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("/banner", GetBannerAsync)
|
||||
.WithDisplayName("Get Banner Items")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
private async Task<IResult> GetNavBarItemsAsync([FromServices] IMediator mediator, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await mediator.Send(new GetWebSiteNavBarCommand(),cancellationToken));
|
||||
|
||||
private async Task<IResult> GetCatalogAsync([FromServices] ISettingService settingService, CancellationToken cancellationToken)
|
||||
{
|
||||
var setting = await settingService.GetSettingAsync(nameof(PersonalizationSetting), cancellationToken);
|
||||
if (setting is PersonalizationSetting personalizationSetting)
|
||||
{
|
||||
return TypedResults.Ok(personalizationSetting.Catalog);
|
||||
}
|
||||
|
||||
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Catalogs not found");
|
||||
}
|
||||
|
||||
private async Task<IResult> GetBannerAsync([FromQuery]BannerSection? section,[FromServices] ISettingService settingService, CancellationToken cancellationToken)
|
||||
{
|
||||
var setting = await settingService.GetSettingAsync(nameof(PersonalizationSetting), cancellationToken);
|
||||
if (setting is not PersonalizationSetting personalizationSetting)
|
||||
throw new BaseApiException(ApiResultStatusCode.BadRequest, "Catalogs not found");
|
||||
if (section != null)
|
||||
return TypedResults.Ok(personalizationSetting.Banners.Where(b => b.Section == section));
|
||||
return TypedResults.Ok(personalizationSetting.Banners);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
namespace Netina.Domain.Enums;
|
||||
|
||||
public enum BannerSection
|
||||
{
|
||||
[Display(Name = "هیچ کدام")]
|
||||
None = 0,
|
||||
[Display(Name = "بنر تخفیف بالای سایت")]
|
||||
TopOff = 1,
|
||||
[Display(Name = "بنر تخفیف بالای سایت - موبایل")]
|
||||
TopOffSm = 2,
|
||||
[Display(Name = "بنر اسلایدری")]
|
||||
Slider = 10,
|
||||
[Display(Name = "بنر اسلایدری - موبایل")]
|
||||
SliderSm = 11,
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
namespace Netina.Domain.MartenEntities.Settings;
|
||||
|
||||
public class BannerItemModel
|
||||
{
|
||||
public string ImageLocation { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Link { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public BannerSection Section { get; set; }
|
||||
}
|
||||
|
||||
public class CatalogItemModel
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string PersianName { get; set; } = string.Empty;
|
||||
public string EnglishName { get; set; } = string.Empty;
|
||||
public string Query { get; set; } = string.Empty;
|
||||
public string ImageLocation { get; set; } = string.Empty;
|
||||
public int Row { get; set; }
|
||||
public bool IsMain { get; set; }
|
||||
public Guid ParentId { get; set; }
|
||||
public string ParentName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class PersonalizationSetting
|
||||
{
|
||||
public List<BannerItemModel> Banners { get; set; } = new();
|
||||
public List<CatalogItemModel> Catalog { get; set; } = new();
|
||||
}
|
Loading…
Reference in New Issue