diff --git a/Api/AutoMapperConfig.cs b/Api/AutoMapperConfig.cs index 8034247..eacfa8d 100644 --- a/Api/AutoMapperConfig.cs +++ b/Api/AutoMapperConfig.cs @@ -21,6 +21,10 @@ namespace Api CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + } diff --git a/Api/Controllers/MiscellaneousImagesController.cs b/Api/Controllers/MiscellaneousImagesController.cs new file mode 100644 index 0000000..3f5ed14 --- /dev/null +++ b/Api/Controllers/MiscellaneousImagesController.cs @@ -0,0 +1,61 @@ +using Domain.BaseData; +using Infrastructure; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Models.BaseData; +using Services.BaseData; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Api.Controllers +{ + [Authorize(Roles = Consts.Developer)] + public class MiscellaneousImagesController : BaseController + { + private readonly IMiscellaneousImageService miscellaneousImageService; + + public MiscellaneousImagesController(IServiceProvider serviceProvider) : base(serviceProvider) + { + miscellaneousImageService = serviceProvider.GetService(); + } + + [HttpGet] + public IActionResult List() + { + var dbList = miscellaneousImageService.GetQueryable().ToList(); + return Ok(Mapper.Map>(dbList)); + } + + [HttpPost] + public IActionResult Add(SaveMiscellaneousImageViewModel model) + { + var dbModel = Mapper.Map(model); + var imageName = SaveImageFromBase64(model.Base64Image); + dbModel.ImageFileName = imageName; + miscellaneousImageService.Add(dbModel); + return Ok(); + } + + [HttpPut] + public IActionResult Update(MiscellaneousImageViewModel model) + { + var dbModel = miscellaneousImageService.GetById(model.Id.Value); + Mapper.Map(model, dbModel); + miscellaneousImageService.Update(dbModel); + return Ok(); + } + + [HttpDelete("{id}")] + public IActionResult Delete(Guid id) + { + if (!miscellaneousImageService.CanBeDeleted(id)) + { + return BadRequest("This image is used in other records and can not be deleted."); + } + miscellaneousImageService.Delete(id); + return Ok(); + } + } +} diff --git a/Api/Controllers/PlantsController.cs b/Api/Controllers/PlantsController.cs index 84e4fe4..d7aaf56 100644 --- a/Api/Controllers/PlantsController.cs +++ b/Api/Controllers/PlantsController.cs @@ -27,6 +27,12 @@ namespace Api.Controllers var dbList = plantsService.GetQueryable().ToList(); return Ok(Mapper.Map>(dbList)); } + [HttpGet("{id}")] + public IActionResult Get(Guid id) + { + var pl = plantsService.GetById(id); + return Ok(Mapper.Map(pl)); + } [HttpPost] public IActionResult Add(SavePlantViewModel model) { diff --git a/BlazorPages/ApiUtils/UserUtils.cs b/BlazorPages/ApiUtils/UserUtils.cs index 1b219db..5d8a9e6 100644 --- a/BlazorPages/ApiUtils/UserUtils.cs +++ b/BlazorPages/ApiUtils/UserUtils.cs @@ -14,10 +14,7 @@ public class UserUtils : IUserUtils _client = client; } - public async Task SendVerificationRequest(object otpModel) - { - return await _client.HttpPost("/api/AUTH/Login",otpModel); - } + public async Task SendSignUpRequest(object accountModel) { @@ -26,37 +23,25 @@ public class UserUtils : IUserUtils } public async Task LoginWithPasswordRequest(object loginModel) { - return await _client.HttpPost("/api/AUTH/LoginWithPassword",loginModel); + return await _client.HttpPost("/api/AUTH/Login",loginModel); } public async Task CheckLogin(bool goToLogin = true) { - return await _client.HttpGet("/api/AUTH/CheckLogin",true,goToLogin); + return await _client.HttpGet("/api/AUTH/Check",true,goToLogin); } - public async Task RefreshToken(object refreshTokenModel) - { - return await _client.HttpPost("/api/Auth/refresh", refreshTokenModel); - } - public async Task SaveEmailAndName(NameAndEmailModel model) - { - var res=await _client.HttpPost("/api/auth/SetNameAndEmail", model); - if (!res.IsSuccessStatusCode) - return null; - return JsonConvert.DeserializeObject(await res.Content.ReadAsStringAsync()); - } + + } public interface IUserUtils { - Task SendVerificationRequest(object otpModel); Task LoginWithPasswordRequest(object loginModel); Task SendSignUpRequest(object accountModel); Task CheckLogin(bool goToLogin = true); - Task RefreshToken(object refreshTokenModel); - Task SaveEmailAndName(NameAndEmailModel model); } \ No newline at end of file diff --git a/BlazorPages/BlazorPages.csproj b/BlazorPages/BlazorPages.csproj index decab26..0549445 100644 --- a/BlazorPages/BlazorPages.csproj +++ b/BlazorPages/BlazorPages.csproj @@ -8,11 +8,11 @@ - - - - - + + + + + @@ -31,6 +31,10 @@ + + + + diff --git a/BlazorPages/Pages/Index.razor b/BlazorPages/Pages/Index.razor index d634392..4fae82b 100644 --- a/BlazorPages/Pages/Index.razor +++ b/BlazorPages/Pages/Index.razor @@ -6,26 +6,20 @@ @page "/" @layout LayoutWithoutMenu - -@if (DataGotten) -{ - -} -
-
-

- © تمامی حقوق برای حقتو محفوظ میباشد -

-
-

- ورژن 1.0 -

-
+ @code { public bool DataGotten { set; get; } @@ -43,14 +37,10 @@ { await LoadingSpinner.HideLoading(); Statics.CurrentLoginInfo = result; - if (!result.HasName) - NavManager.NavigateTo("/NameAndEmail"); - else - NavManager.NavigateTo("/dashboard"); + NavManager.NavigateTo("/dashboard"); } } DataGotten = true; StateHasChanged(); } - } diff --git a/BlazorPages/Pages/Login/Login.razor b/BlazorPages/Pages/Login/Login.razor index 8df6edc..f28ec0f 100644 --- a/BlazorPages/Pages/Login/Login.razor +++ b/BlazorPages/Pages/Login/Login.razor @@ -3,126 +3,56 @@ @using Components @using Models.Identity @layout LayoutWithoutMenu - - - - -