А муха тоже вертолёт
This commit is contained in:
parent
4f873d2502
commit
f1ef3955cf
@ -15,9 +15,9 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
internal class UserLogic : IUserLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUserStorage _storage;
|
||||
private readonly IClientStorage _storage;
|
||||
|
||||
public UserLogic(ILogger<UserLogic> logger, IUserStorage storage)
|
||||
public UserLogic(ILogger<UserLogic> logger, IClientStorage storage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storage = storage;
|
||||
@ -58,7 +58,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
|
||||
}
|
||||
|
||||
public UserViewModel? ReadElemet(UserSearchModel? model)
|
||||
public ClientViewModel? ReadElemet(ClientSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -75,7 +75,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<UserViewModel>? ReadList(UserSearchModel? model)
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||
{
|
||||
|
||||
_logger.LogInformation($"ReadList. ClientID:{model?.ID}");
|
||||
@ -127,7 +127,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
$"LastName:{model.LastName}.Password:{model.Password}.PhoneNumber:{model.PhoneNumber}.Login:{model.Login}." +
|
||||
$"Email:{model.Email}");
|
||||
|
||||
var element = _storage.GetElement(new UserSearchModel
|
||||
var element = _storage.GetElement(new ClientSearchModel
|
||||
{
|
||||
Login = model.Login
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
@using ElectronicsShopContracts.ViewModels
|
||||
|
||||
@model UserViewModel
|
||||
@model ClientViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
|
@ -11,8 +11,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IUserLogic
|
||||
{
|
||||
List<UserViewModel>? ReadList(UserSearchModel? model);
|
||||
UserViewModel? ReadElemet(UserSearchModel model);
|
||||
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||
ClientViewModel? ReadElemet(ClientSearchModel model);
|
||||
|
||||
bool Add(UserBindingModel model);
|
||||
bool Update(UserBindingModel model);
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.SearchModels
|
||||
{
|
||||
public class UserSearchModel
|
||||
public class ClientSearchModel
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public string? Login { get; set; }
|
@ -0,0 +1,15 @@
|
||||
using ElectronicsShopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.SearchModels
|
||||
{
|
||||
public class ImplementerSearchModel
|
||||
{
|
||||
public int UserID { get; set; }
|
||||
public Quakifications Quakifications { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using ElectronicsShopContracts.BindingModels;
|
||||
using ElectronicsShopContracts.SearchModels;
|
||||
using ElectronicsShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.StorageContracts
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||
ClientViewModel? GetElement(ClientSearchModel model);
|
||||
ClientViewModel? Insert(ClientBindingModel model);
|
||||
ClientViewModel? Update(ClientBindingModel model);
|
||||
ClientViewModel? Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using ElectronicsShopContracts.BindingModels;
|
||||
using ElectronicsShopContracts.SearchModels;
|
||||
using ElectronicsShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.StorageContracts
|
||||
{
|
||||
public interface IImplementerStorage
|
||||
{
|
||||
List<ImplementerViewModel> GetFullList();
|
||||
List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model);
|
||||
ImplementerViewModel? GetElement(ClientSearchModel model);
|
||||
ImplementerViewModel? Insert(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Update(ImplementerBindingModel model);
|
||||
ImplementerViewModel? Delete(ImplementerBindingModel model);
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
using ElectronicsShopContracts.BindingModels;
|
||||
using ElectronicsShopContracts.SearchModels;
|
||||
using ElectronicsShopContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.StorageContracts
|
||||
{
|
||||
public interface IUserStorage
|
||||
{
|
||||
List<UserViewModel> GetFullList();
|
||||
List<UserViewModel> GetFilteredList(UserSearchModel model);
|
||||
UserViewModel? GetElement(UserSearchModel model);
|
||||
UserViewModel? Insert(UserBindingModel model);
|
||||
UserViewModel? Update(UserBindingModel model);
|
||||
UserViewModel? Delete(UserBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ElectronicsShopDataModels;
|
||||
using ElectronicsShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.ViewModels
|
||||
{
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
//ID пользователя
|
||||
public int UserID { get; set; }
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using ElectronicsShopDataModels.Enums;
|
||||
using ElectronicsShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int UserID {get; set;}
|
||||
|
||||
public Quakifications Qualification { get; set; } = Quakifications.Отсутствует;
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
using ElectronicsShopDataModels;
|
||||
using ElectronicsShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.ViewModels
|
||||
{
|
||||
public class UserViewModel : IUserModel
|
||||
{
|
||||
|
||||
//ID пользователя
|
||||
public int ID { get; set; }
|
||||
//ID роли (клиент)
|
||||
public int RoleID { get; set; }
|
||||
|
||||
[DisplayName("Имя")]
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Фамилия")]
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Логин")]
|
||||
public string Login { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Почта")]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -11,9 +11,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopDataBaseImplement.Implements
|
||||
{
|
||||
public class UserStorage : IUserStorage
|
||||
public class UserStorage : IClientStorage
|
||||
{
|
||||
public UserViewModel? Delete(UserBindingModel model)
|
||||
public ClientViewModel? Delete(UserBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Users.FirstOrDefault(rec => rec.ID == model.ID);
|
||||
@ -26,7 +26,7 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public UserViewModel? GetElement(UserSearchModel model)
|
||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login) && !model.ID.HasValue)
|
||||
{
|
||||
@ -38,7 +38,7 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
(model.ID.HasValue && x.ID == model.ID)))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<UserViewModel> GetFilteredList(UserSearchModel model)
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Login))
|
||||
{
|
||||
@ -48,13 +48,13 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
return context.Users.Where(x => x.Login.Contains(model.Login)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<UserViewModel> GetFullList()
|
||||
public List<ClientViewModel> GetFullList()
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Users.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public UserViewModel? Insert(UserBindingModel model)
|
||||
public ClientViewModel? Insert(UserBindingModel model)
|
||||
{
|
||||
var newComponent = User.Create(model);
|
||||
if (newComponent == null)
|
||||
@ -67,7 +67,7 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public UserViewModel? Update(UserBindingModel model)
|
||||
public ClientViewModel? Update(UserBindingModel model)
|
||||
{
|
||||
using var context = new Database();
|
||||
var component = context.Users.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
@ -47,7 +47,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
RoleID = model.RoleID
|
||||
};
|
||||
}
|
||||
public static User Create(UserViewModel model)
|
||||
public static User Create(ClientViewModel model)
|
||||
{
|
||||
return new User
|
||||
{
|
||||
@ -76,7 +76,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
Email = model.Email;
|
||||
RoleID = model.RoleID;
|
||||
}
|
||||
public UserViewModel GetViewModel => new()
|
||||
public ClientViewModel GetViewModel => new()
|
||||
{
|
||||
ID = ID,
|
||||
FirstName = FirstName,
|
||||
|
@ -1,6 +1,6 @@
|
||||
@using ElectronicsShopContracts.ViewModels
|
||||
|
||||
@model UserViewModel
|
||||
@model ClientViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
|
Loading…
Reference in New Issue
Block a user