...
This commit is contained in:
@@ -14,9 +14,14 @@ namespace Back.Controllers
|
||||
{
|
||||
_sBase = sBase;
|
||||
}
|
||||
[HttpGet("BasePrice")]
|
||||
public async Task<ActionResult<List<BasePriceDto>>> GetBasePrice()
|
||||
[HttpGet("Pricing")]
|
||||
public async Task<ActionResult<List<BasePriceDto>>> Pricing()
|
||||
=> Ok(await _sBase.GetBasePrice());
|
||||
|
||||
[HttpGet("DateTimeServer")]
|
||||
public async Task<ActionResult<DateTime>> DateTimeServer()
|
||||
=> Ok(DateTime.Now);
|
||||
[HttpGet("LastBlog/{Count}")]
|
||||
public async Task<ActionResult<List<BlogDto>>> LastBlog(int Count)
|
||||
=> Ok(await _sBase.GetBlog(Count));
|
||||
}
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@
|
||||
public int ID { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Text { get; set; }
|
||||
public byte[]? Photo { get; set; }
|
||||
public string? Photo { get; set; }
|
||||
public string Date { get; set; }
|
||||
public string Time { get; set; }
|
||||
public bool Status { get; set; }
|
||||
|
@@ -24,7 +24,7 @@ builder.Services.AddCors(options =>
|
||||
options.AddPolicy(origins,
|
||||
policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:5107")
|
||||
policy.WithOrigins("https://localhost:7224")
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
|
@@ -8,20 +8,34 @@ namespace Back.Services
|
||||
public class ServBase
|
||||
{
|
||||
private readonly IAsyncRepository<Pricing> _repoPricing;
|
||||
public ServBase(IAsyncRepository<Pricing> repoPricing)
|
||||
private readonly IAsyncRepository<Blog> _repoBlog;
|
||||
public ServBase(IAsyncRepository<Pricing> repoPricing, IAsyncRepository<Blog> repoBlog)
|
||||
{
|
||||
_repoPricing = repoPricing;
|
||||
_repoBlog = repoBlog;
|
||||
}
|
||||
public async Task<List<BasePriceDto>> GetBasePrice()
|
||||
{
|
||||
return await _repoPricing.GetAll().Select(x => new BasePriceDto
|
||||
{
|
||||
Price = x.Price,
|
||||
CalculationType = x.CalculationTypeID==1 ? "واحدی"
|
||||
: x.CalculationTypeID == 1 && x.PermissionID==16 ? "هر ارسال"
|
||||
CalculationType = x.CalculationTypeID == 1 && x.PermissionID == 16 ? "هر ارسال"
|
||||
:x.CalculationTypeID== 1 && x.PermissionID != 16 ? "واحدی"
|
||||
: x.CalculationTypeID == 2 ? "نامحدود" : "روزانه",
|
||||
PermissionID=x.PermissionID,
|
||||
}).ToListAsync();
|
||||
}
|
||||
public async Task<List<BlogDto>> GetBlog(int count)
|
||||
{
|
||||
return await _repoBlog.Get(w=>w.Status).OrderByDescending(o=>o.ID).Take(count)
|
||||
.Select(s=>new BlogDto
|
||||
{
|
||||
Title = s.Title,
|
||||
Date=s.Date,
|
||||
ID=s.ID,
|
||||
Photo=string.IsNullOrEmpty(s.Photo) ? "blog-grid-1.jpg" : s.Photo
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user