оно раотает
This commit is contained in:
parent
139326a4b8
commit
efe87a6a04
@ -13,7 +13,6 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
using var context = new PlumbingRepairDataBase();
|
using var context = new PlumbingRepairDataBase();
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.Orders)
|
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -22,12 +21,16 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
|||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
|
}
|
||||||
|
if (model.Id.HasValue)
|
||||||
|
{
|
||||||
|
var res = GetElement(model);
|
||||||
|
return res != null ? new() { res } : new();
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(model.Email))
|
if (!string.IsNullOrEmpty(model.Email))
|
||||||
{
|
{
|
||||||
using var context = new PlumbingRepairDataBase();
|
using var context = new PlumbingRepairDataBase();
|
||||||
return context.Clients
|
return context.Clients
|
||||||
.Include(x => x.Orders)
|
|
||||||
.Where(x => x.Email.Contains(model.Email))
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -36,18 +39,21 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public ClientViewModel? GetElement(ClientSearchModel model)
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ClientFIO) &&
|
||||||
|
string.IsNullOrEmpty(model.Email) &&
|
||||||
|
string.IsNullOrEmpty(model.Password) &&
|
||||||
|
!model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
using var context = new PlumbingRepairDataBase();
|
using var context = new PlumbingRepairDataBase();
|
||||||
if (model.Id.HasValue)
|
var temp = context.Clients
|
||||||
{
|
.FirstOrDefault(x => (string.IsNullOrEmpty(model.ClientFIO) || x.ClientFIO == model.ClientFIO) &&
|
||||||
return context.Clients
|
(string.IsNullOrEmpty(model.Email) || x.Email == model.Email) &&
|
||||||
.FirstOrDefault(x => (x.Id == model.Id))?.GetViewModel;
|
(string.IsNullOrEmpty(model.Password) || x.Password == model.Password) &&
|
||||||
}
|
(!model.Id.HasValue || x.Id == model.Id))
|
||||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
|
?.GetViewModel;
|
||||||
{
|
return temp;
|
||||||
return context.Clients
|
|
||||||
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))?.GetViewModel;
|
|
||||||
}
|
|
||||||
return new();
|
|
||||||
}
|
}
|
||||||
public ClientViewModel? Insert(ClientBindingModel model)
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
|
@ -10,8 +10,10 @@ namespace PlumbingRepairDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
if (model.MessageId == null)
|
if (string.IsNullOrEmpty(model.MessageId))
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
using var context = new PlumbingRepairDataBase();
|
using var context = new PlumbingRepairDataBase();
|
||||||
return context.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
return context.Messages.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ using PlumbingRepairDatabaseImplement;
|
|||||||
namespace PlumbingRepairDatabaseImplement.Migrations
|
namespace PlumbingRepairDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PlumbingRepairDataBase))]
|
[DbContext(typeof(PlumbingRepairDataBase))]
|
||||||
[Migration("20230429174158_WithMessage")]
|
[Migration("20230430082314_WithMessage")]
|
||||||
partial class WithMessage
|
partial class WithMessage
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
@ -10,13 +10,9 @@ namespace PlumbingRepairDatabaseImplement.Models
|
|||||||
[Key]
|
[Key]
|
||||||
public string MessageId { get; private set; } = string.Empty;
|
public string MessageId { get; private set; } = string.Empty;
|
||||||
public int? ClientId { get; private set; }
|
public int? ClientId { get; private set; }
|
||||||
[Required]
|
|
||||||
public string SenderName { get; private set; } = string.Empty;
|
public string SenderName { get; private set; } = string.Empty;
|
||||||
[Required]
|
public DateTime DateDelivery { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
public DateTime DateDelivery { get; private set; }
|
|
||||||
[Required]
|
|
||||||
public string Subject { get; private set; } = string.Empty;
|
public string Subject { get; private set; } = string.Empty;
|
||||||
[Required]
|
|
||||||
public string Body { get; private set; } = string.Empty;
|
public string Body { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public virtual Client? Client { get; set; }
|
public virtual Client? Client { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user