Создание бизнес-логики
This commit is contained in:
parent
eed383ce2f
commit
6543543d80
@ -5,6 +5,8 @@ VisualStudioVersion = 17.3.32922.545
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicView", "VetClinicView\VetClinicView.csproj", "{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicBusinessLogic", "VetClinicBusinessLogic\VetClinicBusinessLogic.csproj", "{E3827255-F30E-4DD8-A18E-A542280F631F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +17,10 @@ Global
|
||||
{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{278BCF5A-EAE2-41FF-A5FC-5376AB7FE6E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E3827255-F30E-4DD8-A18E-A542280F631F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.Enums;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class ClientBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Pet { get; set; }
|
||||
public string PetName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class EmployeeBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Specialization { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class MailConfigBindingModel
|
||||
{
|
||||
public string MailLogin { get; set; }
|
||||
public string MailPassword { get; set; }
|
||||
public string SmtpClientHost { get; set; }
|
||||
public int SmtpClientPort { get; set; }
|
||||
public string PopHost { get; set; }
|
||||
public int PopPort { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class MailSendInfoBindingModel
|
||||
{
|
||||
public string MailAddress { get; set; }
|
||||
public string Subject { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class PaymentBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public decimal Remains { get; set; }
|
||||
public DateTime DateOfPayment { get; set; }
|
||||
public int VisitId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class PaymentDateBindingModel
|
||||
{
|
||||
public DateTime DateTo { get; set; }
|
||||
public DateTime DateFrom { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class ServiceBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace VetClinicBusinessLogic.BindingModels
|
||||
{
|
||||
public class VisitBindingModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public DateTime VisitsDate { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public Dictionary<int, string> VisitServices { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ClientLogic
|
||||
{
|
||||
private IClientStorage clientStorage;
|
||||
public ClientLogic(IClientStorage clientS)
|
||||
{
|
||||
clientStorage = clientS;
|
||||
}
|
||||
public void CreateOrUpdate(ClientBindingModel model)
|
||||
{
|
||||
var element = clientStorage.GetElement(new ClientBindingModel
|
||||
{
|
||||
Phone = model.Phone
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть пользователь с таким телефоном");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
clientStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
clientStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(ClientBindingModel model)
|
||||
{
|
||||
var element = clientStorage.GetElement(new ClientBindingModel
|
||||
{
|
||||
Id =
|
||||
model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
clientStorage.Delete(model);
|
||||
}
|
||||
|
||||
public List<ClientViewModel> Read(ClientBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return clientStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<ClientViewModel> { clientStorage.GetElement(model)
|
||||
};
|
||||
}
|
||||
return clientStorage.GetFilteredList(model);
|
||||
}
|
||||
public ClientViewModel GetClient(ClientBindingModel binding)
|
||||
{
|
||||
return clientStorage.GetElement(binding);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class EmployeeLogic
|
||||
{
|
||||
private readonly IEmployeeStorage _employeeStorage;
|
||||
public EmployeeLogic(IEmployeeStorage employeeStorage)
|
||||
{
|
||||
_employeeStorage = employeeStorage;
|
||||
}
|
||||
public List<EmployeeViewModel> Read(EmployeeBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _employeeStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<EmployeeViewModel> { _employeeStorage.GetElement(model)
|
||||
};
|
||||
}
|
||||
return _employeeStorage.GetFilteredList(model);
|
||||
}
|
||||
|
||||
public EmployeeViewModel Check(EmployeeBindingModel model)
|
||||
{
|
||||
return _employeeStorage.GetElement(model);
|
||||
}
|
||||
public void CreateOrUpdate(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel
|
||||
{
|
||||
Phone = model.Phone
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new Exception("Уже есть сотрудник с таким телефоном");
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_employeeStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_employeeStorage.Insert(model);
|
||||
}
|
||||
}
|
||||
public void Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var element = _employeeStorage.GetElement(new EmployeeBindingModel
|
||||
{
|
||||
Id =
|
||||
model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Элемент не найден");
|
||||
}
|
||||
_employeeStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
71
VetClinic/VetClinicBusinessLogic/BusinessLogic/MailWorker.cs
Normal file
71
VetClinic/VetClinicBusinessLogic/BusinessLogic/MailWorker.cs
Normal file
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class MailWorker
|
||||
{
|
||||
protected string _mailLogin;
|
||||
protected string _mailPassword;
|
||||
protected string _smtpClientHost;
|
||||
protected int _smtpClientPort;
|
||||
protected string _popHost;
|
||||
protected int _popPort;
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
_mailLogin = config.MailLogin;
|
||||
_mailPassword = config.MailPassword;
|
||||
_smtpClientHost = config.SmtpClientHost;
|
||||
_smtpClientPort = config.SmtpClientPort;
|
||||
_popHost = config.PopHost;
|
||||
_popPort = config.PopPort;
|
||||
}
|
||||
public async void MailSendAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(info.MailAddress) ||
|
||||
string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
private async Task SendMailAsync(MailSendInfoBindingModel info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost,
|
||||
_smtpClientPort);
|
||||
try
|
||||
{
|
||||
objMailMessage.From = new MailAddress(_mailLogin);
|
||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||
objMailMessage.Subject = info.Subject;
|
||||
objMailMessage.Body = info.Text;
|
||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class PaymentLogic
|
||||
{
|
||||
private readonly IPaymentStorage _PaymentsStorage;
|
||||
|
||||
public PaymentLogic(IPaymentStorage PaymentsStorage)
|
||||
{
|
||||
_PaymentsStorage = PaymentsStorage;
|
||||
}
|
||||
|
||||
public List<PaymentViewModel> Read(PaymentBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _PaymentsStorage.GetFullList();
|
||||
}
|
||||
if (model.Id != 0)
|
||||
{
|
||||
return new List<PaymentViewModel> { _PaymentsStorage.GetElement(model) };
|
||||
}
|
||||
return _PaymentsStorage.GetFilteredList(model);
|
||||
}
|
||||
|
||||
public void CreateOrUpdate(PaymentBindingModel model)
|
||||
{
|
||||
if (model.Id != 0)
|
||||
{
|
||||
_PaymentsStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_PaymentsStorage.Insert(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Delete(PaymentBindingModel model)
|
||||
{
|
||||
var element = _PaymentsStorage.GetElement(new PaymentBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Услуга не найдена");
|
||||
}
|
||||
_PaymentsStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
182
VetClinic/VetClinicBusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
182
VetClinic/VetClinicBusinessLogic/BusinessLogic/ReportLogic.cs
Normal file
@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.BusinessLogic.OfficePackage;
|
||||
using VetClinicBusinessLogic.BusinessLogic.OfficePackage.Models;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ReportLogic
|
||||
{
|
||||
private readonly IServiceStorage _serviceStorage;
|
||||
private readonly IVisitStorage _VisitStorage;
|
||||
private readonly ReportToExcel _saveToExcel;
|
||||
private readonly ReportToWord _saveToWord;
|
||||
private readonly ReportToPdf _saveToPdf;
|
||||
private readonly IPaymentStorage paymentStorage;
|
||||
public ReportLogic(IVisitStorage VisitStorage, IPaymentStorage paymentStorage, IServiceStorage serviceStorage,
|
||||
ReportToExcel saveToExcel, ReportToWord saveToWord, ReportToPdf saveToPdf)
|
||||
{
|
||||
this.paymentStorage = paymentStorage;
|
||||
_VisitStorage = VisitStorage;
|
||||
_serviceStorage = serviceStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
public List<ReportVisitServiceViewModel> GetVisitService(int UserId)
|
||||
{
|
||||
var Visits = _VisitStorage.GetFilteredList(new VisitBindingModel()
|
||||
{
|
||||
ClientId = UserId
|
||||
});
|
||||
var list = new List<ReportVisitServiceViewModel>();
|
||||
foreach (var Visit in Visits)
|
||||
{
|
||||
var record = new ReportVisitServiceViewModel
|
||||
{
|
||||
VisitDate = Visit.VisitsDate,
|
||||
Services = new List<string>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var service in Visit.VisitServices)
|
||||
{
|
||||
record.Services.Add(service.Value);
|
||||
record.TotalCount += 1;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public List<ReportServiceVisitViewModel> GetServiceVisit(int UserId)
|
||||
{
|
||||
var services = _serviceStorage.GetFullList();
|
||||
var list = new List<ReportServiceVisitViewModel>();
|
||||
foreach (var service in services)
|
||||
{
|
||||
var record = new ReportServiceVisitViewModel
|
||||
{
|
||||
Name = service.Name,
|
||||
Visits = new List<DateTime>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var visit in service.VisitServices)
|
||||
{
|
||||
record.Visits.Add(visit.Value);
|
||||
record.TotalCount += 1;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public void SaveVisitServiceToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReportVisitService(new ExcelInfoVisitService
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список визитов",
|
||||
VisitServices = GetVisitService(model.UserId)
|
||||
});
|
||||
}
|
||||
public void SaveServiceVisitToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReportServiceVisit(new ExcelInfoServiceVisit
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список услуг",
|
||||
VisitServices = GetServiceVisit(model.UserId)
|
||||
});
|
||||
}
|
||||
public void SaveVisitServiceToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDocVisitService(new WordInfoVisitService
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Визиты по услугам",
|
||||
VisitServices = GetVisitService(model.UserId)
|
||||
});
|
||||
}
|
||||
public void SaveServiceVisitToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDocServiceVisit(new WordInfoServiceVisit
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Услуги по визитам",
|
||||
VisitServices = GetServiceVisit(model.UserId)
|
||||
});
|
||||
}
|
||||
public List<ReportVisitViewModel> GetOrders(ReportBindingModel model)
|
||||
{
|
||||
return _VisitStorage.GetFilteredListDate(new VisitBindingModel
|
||||
{
|
||||
DateFrom =
|
||||
model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportVisitViewModel
|
||||
{
|
||||
DateCreate = x.VisitsDate,
|
||||
ClientName = x.ClientName,
|
||||
Sum = x.Sum
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
public ReportServiceViewModel GetServices(ReportBindingModel model)
|
||||
{
|
||||
var list = _VisitStorage.GetFilteredListDate(new VisitBindingModel
|
||||
{
|
||||
DateFrom =
|
||||
model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
Dictionary<string, int> dic = new Dictionary<string, int>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
foreach (var item2 in item.VisitServices)
|
||||
{
|
||||
if (dic.ContainsKey(item2.Value))
|
||||
{
|
||||
dic[item2.Value]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
dic[item2.Value] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return new ReportServiceViewModel()
|
||||
{
|
||||
Sum = paymentStorage.GetElementFirstLast(new PaymentDateBindingModel()).Remains,
|
||||
Services = dic
|
||||
};
|
||||
}
|
||||
public void SaveOrdersToPdfFileVisit(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список визитов",
|
||||
DateFrom = model.DateFrom.Value,
|
||||
DateTo = model.DateTo.Value,
|
||||
Visits = GetOrders(model)
|
||||
});
|
||||
}
|
||||
public void SaveOrdersToPdfFileService(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDocService(new PdfInfoService
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список визитов",
|
||||
DateFrom = model.DateFrom.Value,
|
||||
DateTo = model.DateTo.Value,
|
||||
Services = GetServices(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ServiceLogic
|
||||
{
|
||||
private readonly IServiceStorage _ServicesStorage;
|
||||
|
||||
public ServiceLogic(IServiceStorage ServicesStorage)
|
||||
{
|
||||
_ServicesStorage = ServicesStorage;
|
||||
}
|
||||
|
||||
public List<ServiceViewModel> Read(ServiceBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _ServicesStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<ServiceViewModel> { _ServicesStorage.GetElement(model) };
|
||||
}
|
||||
return _ServicesStorage.GetFilteredList(model);
|
||||
}
|
||||
|
||||
public void CreateOrUpdate(ServiceBindingModel model)
|
||||
{
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_ServicesStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ServicesStorage.Insert(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Delete(ServiceBindingModel model)
|
||||
{
|
||||
var element = _ServicesStorage.GetElement(new ServiceBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Услуга не найдена");
|
||||
}
|
||||
_ServicesStorage.Delete(model);
|
||||
}
|
||||
}
|
||||
}
|
67
VetClinic/VetClinicBusinessLogic/BusinessLogic/VisitLogic.cs
Normal file
67
VetClinic/VetClinicBusinessLogic/BusinessLogic/VisitLogic.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.Interfaces;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.BusinessLogic
|
||||
{
|
||||
internal class VisitLogic
|
||||
{
|
||||
private readonly IVisitStorage _VisitsStorage;
|
||||
private readonly IServiceStorage serviceStorage;
|
||||
|
||||
public VisitLogic(IVisitStorage VisitsStorage, IServiceStorage serviceStorage)
|
||||
{
|
||||
this.serviceStorage = serviceStorage;
|
||||
_VisitsStorage = VisitsStorage;
|
||||
}
|
||||
|
||||
public List<VisitViewModel> Read(VisitBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return _VisitsStorage.GetFullList();
|
||||
}
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return new List<VisitViewModel> { _VisitsStorage.GetElement(model) };
|
||||
}
|
||||
return _VisitsStorage.GetFilteredList(model);
|
||||
}
|
||||
|
||||
public void CreateOrUpdate(VisitBindingModel model)
|
||||
{
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
_VisitsStorage.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_VisitsStorage.Insert(model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Delete(VisitBindingModel model)
|
||||
{
|
||||
var element = _VisitsStorage.GetElement(new VisitBindingModel
|
||||
{
|
||||
Id = model.Id
|
||||
});
|
||||
if (element == null)
|
||||
{
|
||||
throw new Exception("Услуга не найдена");
|
||||
}
|
||||
_VisitsStorage.Delete(model);
|
||||
}
|
||||
public List<VisitViewModel> ReadEmployee(VisitBindingModel model)
|
||||
{
|
||||
return _VisitsStorage.GetFilteredListEmployee(model);
|
||||
}
|
||||
}
|
||||
}
|
9
VetClinic/VetClinicBusinessLogic/Enums/Enums.cs
Normal file
9
VetClinic/VetClinicBusinessLogic/Enums/Enums.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace VetClinicBusinessLogic.Enums
|
||||
{
|
||||
public enum Role
|
||||
{
|
||||
Клиент = 0,
|
||||
|
||||
Сотрудник = 1
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.Interfaces
|
||||
{
|
||||
public interface IClientStorage
|
||||
{
|
||||
List<ClientViewModel> GetFullList();
|
||||
|
||||
List<ClientViewModel> GetFilteredList(ClientBindingModel model);
|
||||
|
||||
ClientViewModel GetElement(ClientBindingModel model);
|
||||
|
||||
void Insert(ClientBindingModel model);
|
||||
|
||||
void Update(ClientBindingModel model);
|
||||
|
||||
void Delete(ClientBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.Interfaces
|
||||
{
|
||||
public interface IEmployeeStorage
|
||||
{
|
||||
List<EmployeeViewModel> GetFullList();
|
||||
|
||||
List<EmployeeViewModel> GetFilteredList(EmployeeBindingModel model);
|
||||
|
||||
EmployeeViewModel GetElement(EmployeeBindingModel model);
|
||||
|
||||
void Insert(EmployeeBindingModel model);
|
||||
|
||||
void Update(EmployeeBindingModel model);
|
||||
|
||||
void Delete(EmployeeBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.Interfaces
|
||||
{
|
||||
public interface IPaymentStorage
|
||||
{
|
||||
List<PaymentViewModel> GetFullList();
|
||||
|
||||
List<PaymentViewModel> GetFilteredList(PaymentBindingModel model);
|
||||
|
||||
PaymentViewModel GetElement(PaymentBindingModel model);
|
||||
|
||||
void Insert(PaymentBindingModel model);
|
||||
|
||||
void Update(PaymentBindingModel model);
|
||||
|
||||
PaymentViewModel GetElementFirstLast(PaymentDateBindingModel model);
|
||||
void Delete(PaymentBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.Interfaces
|
||||
{
|
||||
public interface IServiceStorage
|
||||
{
|
||||
List<ServiceViewModel> GetFullList();
|
||||
|
||||
List<ServiceViewModel> GetFilteredList(ServiceBindingModel model);
|
||||
|
||||
ServiceViewModel GetElement(ServiceBindingModel model);
|
||||
|
||||
void Insert(ServiceBindingModel model);
|
||||
|
||||
void Update(ServiceBindingModel model);
|
||||
|
||||
void Delete(ServiceBindingModel model);
|
||||
}
|
||||
}
|
26
VetClinic/VetClinicBusinessLogic/Interfaces/IVisitStorage.cs
Normal file
26
VetClinic/VetClinicBusinessLogic/Interfaces/IVisitStorage.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VetClinicBusinessLogic.BindingModels;
|
||||
using VetClinicBusinessLogic.ViewModels;
|
||||
|
||||
namespace VetClinicBusinessLogic.Interfaces
|
||||
{
|
||||
public interface IVisitStorage
|
||||
{
|
||||
List<VisitViewModel> GetFullList();
|
||||
|
||||
List<VisitViewModel> GetFilteredList(VisitBindingModel model);
|
||||
VisitViewModel GetElement(VisitBindingModel model);
|
||||
List<VisitViewModel> GetFilteredListEmployee(VisitBindingModel model);
|
||||
List<VisitViewModel> GetFilteredListDate(VisitBindingModel model);
|
||||
|
||||
void Insert(VisitBindingModel model);
|
||||
|
||||
void Update(VisitBindingModel model);
|
||||
|
||||
void Delete(VisitBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
[DataContract]
|
||||
public class ClientViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Pet { get; set; }
|
||||
public string PetName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class EmployeeViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Specialization { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Phone { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class PaymentViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public decimal Remains { get; set; }
|
||||
public DateTime? DateOfPayment { get; set; }
|
||||
public int VisitId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ReportServiceViewModel
|
||||
{
|
||||
public decimal Sum { get; set; }
|
||||
public Dictionary<string, int> Services { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ReportServiceVisitViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public List<DateTime> Visits { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ReportViewerServiceModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ReportVisitServiceViewModel
|
||||
{
|
||||
public DateTime? VisitDate { get; set; }
|
||||
public List<string> Services { get; set; }
|
||||
public int TotalCount { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ReportVisitViewModel
|
||||
{
|
||||
public DateTime DateCreate { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class ServiceViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
public Dictionary<int, DateTime> VisitServices { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VetClinicBusinessLogic.ViewModels
|
||||
{
|
||||
public class VisitViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime VisitsDate { get; set; }
|
||||
public decimal Sum { get; set; }
|
||||
public int? EmployeeId { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
public int ServiceId { get; set; }
|
||||
public string ServiceName { get; set; }
|
||||
public string ClientName { get; set; }
|
||||
public string? EmployeeName { get; set; }
|
||||
public Dictionary<int, string> VisitServices { get; set; }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user