подредактировал для менеджера
This commit is contained in:
parent
3297776066
commit
28b2066e9d
@ -159,14 +159,23 @@ namespace CarCenterBusinessLogic.BusinessLogics
|
||||
|
||||
_logger.LogInformation("Manager. ManagerFIO: {ManagerFIO}. ManagerLogin: {ManagerLogin}. Id: {Id}", model.ManagerFIO, model.ManagerLogin, model.Id);
|
||||
|
||||
var element = _managerStorage.GetElement(new ManagerSearchModel
|
||||
var element1 = _managerStorage.GetElement(new ManagerSearchModel
|
||||
{
|
||||
ManagerEmail = model.ManagerEmail
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
var element2 = _managerStorage.GetElement(new ManagerSearchModel
|
||||
{
|
||||
throw new InvalidOperationException("менеджер с таким логином уже есть");
|
||||
ManagerLogin = model.ManagerLogin
|
||||
});
|
||||
|
||||
if (element1 != null && element1.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Менеджер с такой почтой уже есть");
|
||||
}
|
||||
|
||||
if (element2 != null && element2.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Менеджер с такой почтой уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace CarCenterDataBaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=CarCenter;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=CarCenter2;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
|
@ -24,7 +24,10 @@ namespace CarCenterDataBaseImplement.Implements
|
||||
{
|
||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.ManagerLogin)) { return null; }
|
||||
using var context = new CarCenterDataBase();
|
||||
return context.Managers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.ManagerLogin) && !string.IsNullOrEmpty(model.ManagerPassword) && x.ManagerLogin.Equals(model.ManagerLogin) && x.ManagerPassword.Equals(model.ManagerPassword)))?.GetViewModel; ;
|
||||
if (!string.IsNullOrEmpty(model.ManagerLogin) && string.IsNullOrEmpty(model.ManagerPassword))
|
||||
return context.Managers.FirstOrDefault(x => x.ManagerLogin == model.ManagerLogin)?.GetViewModel;
|
||||
else
|
||||
return context.Managers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.ManagerLogin) && !string.IsNullOrEmpty(model.ManagerPassword) && x.ManagerLogin.Equals(model.ManagerLogin) && x.ManagerPassword.Equals(model.ManagerPassword)))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ManagerViewModel> GetFilteredList(ManagerSearchModel model)
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace CarCenterDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDataBase))]
|
||||
[Migration("20240529142629_InitialCreate")]
|
||||
[Migration("20240529155030_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
@ -81,6 +81,8 @@ namespace ManagerApp.Controllers
|
||||
{
|
||||
if (password1 == password2 && _data.Register(new() { ManagerEmail = email, ManagerLogin = login, ManagerFIO = fio, ManagerNumber = number, ManagerPassword = password1 }))
|
||||
{
|
||||
var manager = _data.Login(login, password1);
|
||||
UserManager.manager = manager;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user