still got work to do

This commit is contained in:
Никита Волков 2024-08-27 16:24:55 +04:00
parent 9981e2faa1
commit 267a137101
69 changed files with 1014 additions and 181 deletions

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class CosmeticLogic : ICosmeticLogic
{

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class LaborCostLogic : ILaborCostLogic
{

View File

@ -0,0 +1,90 @@
using Microsoft.Extensions.Logging;
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class MessageInfoLogic : IMessageInfoLogic
{
private readonly ILogger _logger;
private readonly IMessageInfoStorage _messageInfoStorage;
private readonly IStoreKeeperStorage _staffmemberStorage;
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage, IStoreKeeperStorage staffmemberStorage)
{
_logger = logger;
_messageInfoStorage = messageInfoStorage;
_staffmemberStorage = staffmemberStorage;
}
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
{
_logger.LogInformation("ReadList. MessageId:{MessageId}. StorekeeperId:{StorekeeperId}", model?.MessageId, model?.StorekeeperId);
var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Create(MessageInfoBindingModel model)
{
CheckModel(model);
if (_messageInfoStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
private void CheckModel(MessageInfoBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.MessageId))
{
throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId));
}
if (string.IsNullOrEmpty(model.SenderName))
{
throw new ArgumentNullException("Не указана почта", nameof(model.SenderName));
}
if (string.IsNullOrEmpty(model.Subject))
{
throw new ArgumentNullException("Не указана тема", nameof(model.Subject));
}
if (string.IsNullOrEmpty(model.Body))
{
throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject));
}
_logger.LogInformation("MessageInfo. MessageId:{MessageId}. SenderName:{SenderName}. Subject:{Subject}. Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body);
var element = _staffmemberStorage.GetElement(new StoreKeeperSearchModel
{
StoreKeeperEmail = model.SenderName
});
if (element == null)
{
_logger.LogWarning("Не удалоссь найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName);
}
else
{
model.StorekeeperId = element.Id;
}
}
}
}

View File

@ -11,7 +11,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class OrderLogic : IOrderLogic
{

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class ProcedureLogic : IProcedureLogic
{

View File

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioBusinessLogic.OfficePackage;
using BeautyStudioContracts.ViewModels;
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.SearchModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.Implements;
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class ReportLogic : IReportLogic
{
private readonly IServiceStorage _serviceStorage;
private readonly IProcedureStorage _procedureStorage;
private readonly ICosmeticStorage _cosmeticStorage;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(IServiceStorage serviceStorage, IProcedureStorage procedureStorage, ICosmeticStorage cosmeticStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
{
_serviceStorage = serviceStorage;
_procedureStorage = procedureStorage;
_cosmeticStorage = cosmeticStorage;
_saveToExcel = saveToExcel;
_saveToWord = saveToWord;
_saveToPdf = saveToPdf;
}
//Получение косметики по процедуре
public List<ReportCosmeticProceduresViewModel> GetCosmeticProcedures()
{
var cosmetics = _cosmeticStorage.GetFullList();
var procedures = _procedureStorage.GetFullList();
var list = new List<ReportCosmeticProceduresViewModel>();
foreach (var cosmetic in cosmetics)
{
var record = new ReportCosmeticProceduresViewModel
{
CosmeticName = cosmetic.CosmeticName,
Procedures = new List<string>(),
};
foreach (var procedure in procedures)
{
if (cosmetic.CosmeticProcedure.ContainsKey(procedure.Id))
{
record.Procedures.Add(new(procedure.ProcedureName));
}
}
list.Add(record);
}
return list;
}
public List<ReportServicesViewModel> GetServices(ReportServiceBindingModel model)
{
List<ReportServicesViewModel> r = _serviceStorage.GetFullList()
.Select(x => new ReportServicesViewModel
{
Id = x.Id,
ServiceName = x.ServiceName,
Cosmetics = x.ServiceCosmetic,
Procedures = x.ServiceProcedure,
ServicePrice = x.ServiceProcedure.Sum(kv => kv.Value.Item1.ProcedurePrice) +
x.ServiceCosmetic.Sum(kv => kv.Value.Item1.CosmeticPrice)
}).ToList();
return r;
}
public void SaveCosmeticProceduresToWordFile(ReportBindingModel model)
{
_saveToWord.CreateDoc(new WordInfo
{
FileName = model.FileName,
Title = "Список процедур по косметике",
CosmeticProcedures = GetCosmeticProcedures()
});
}
public void SaveCosmeticProceduresToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список процедур по косметике",
CosmeticProcedures = GetCosmeticProcedures()
});
}
public void SaveServicesToPdfFile(ReportServiceBindingModel model)
{
var report = new PdfInfo
{
FileName = model.FileName,
Title = "Список услуг",
Services = GetServices(model)
};
_saveToPdf.CreateReport(report);
}
}
}

View File

@ -10,7 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class ServiceLogic : IServiceLogic
{

View File

@ -5,7 +5,7 @@ using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace BeautyStudioBusinessLogic.BusinessLogics
namespace BeautyStudioBusinessLogic.BusinessLogic
{
public class StoreKeeperLogic : IStoreKeeperLogic
{

View File

@ -1,12 +1,12 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage
namespace BeautyStudioBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToExcel
{

View File

@ -1,5 +1,5 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using BeautyStudioContracts.ViewModels;
using System;
using System.Collections;
@ -8,7 +8,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogics.OfficePackage
namespace BeautyStudioBusinessLogic.OfficePackage
{
/// <summary>
/// Абстрактный класс для создания отчета Pdf

View File

@ -1,12 +1,12 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage
namespace BeautyStudioBusinessLogic.OfficePackage
{
public abstract class AbstractSaveToWord
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums
namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums
{
public enum ExcelStyleInfoType
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums
namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums
{
public enum PdfParagraphAlignmentType
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperEnums
namespace BeautyStudioBusinessLogic.OfficePackage.HelperEnums
{
public enum WordJustificationType
{

View File

@ -1,11 +1,11 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class ExcelCellParameters
{

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfo
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class ExcelMergeParameters
{

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class PdfInfo
{

View File

@ -1,11 +1,11 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class PdfParagraph
{

View File

@ -1,11 +1,11 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class PdfRowParameters
{

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class WordInfo
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class WordParagraph
{

View File

@ -1,11 +1,11 @@
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.HelperModels
namespace BeautyStudioBusinessLogic.OfficePackage.HelperModels
{
public class WordTextProperties
{

View File

@ -3,15 +3,15 @@ using DocumentFormat.OpenXml.Office2013.Excel;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioBusinesLogic.OfficePackage.Implements
namespace BeautyStudioBusinessLogic.OfficePackage.Implements
{
public class SaveToExcel : AbstractSaveToExcel
{

View File

@ -1,16 +1,16 @@
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BeautyStudioBusinesLogics.OfficePackage;
using BeautyStudioBusinessLogic.OfficePackage;
namespace BeautyStudioBusinesLogic.OfficePackage.Implements
namespace BeautyStudioBusinessLogic.OfficePackage.Implements
{
public class SaveToPdf : AbstractSaveToPdf
{

View File

@ -1,8 +1,8 @@
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using BeautyStudioBusinesLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinesLogic.OfficePackage.HelperModels;
using BeautyStudioBusinessLogic.OfficePackage.HelperEnums;
using BeautyStudioBusinessLogic.OfficePackage.HelperModels;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,7 +13,7 @@ using static System.Net.Mime.MediaTypeNames;
using Document = DocumentFormat.OpenXml.Wordprocessing.Document;
using Text = DocumentFormat.OpenXml.Wordprocessing.Text;
namespace BeautyStudioBusinesLogic.OfficePackage.Implements
namespace BeautyStudioBusinessLogic.OfficePackage.Implements
{
public class SaveToWord : AbstractSaveToWord
{

View File

@ -10,7 +10,6 @@ namespace BeautyStudioContracts.BindingModels
public class MessageInfoBindingModel : IMessageInfoModel
{
public string MessageId { get; set; } = string.Empty;
public int? WorkerId { get; set; }
public int? StorekeeperId { get; set; }
public string SenderName { get; set; } = string.Empty;
public string Subject { get; set; } = string.Empty;

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BeautyStudioContracts.BindingModels;
namespace BeautyStudioContracts.BindingModels
{
public class ReportBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set;}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.BindingModels
{
public class ReportOrderBindingModel
{
public string FileName { get; set; } = string.Empty;
public DateTime? DateFrom { get; set; } = DateTime.Now;
public DateTime? DateTo { get; set; } = DateTime.Now;
public int? WorkerId { get; set; }
public string? Email { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.BindingModels
{
public class ReportServiceBindingModel
{
public string FileName { get; set; } = string.Empty;
public int? StorekeeperId { get; set; }
public string? Email { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.BusinessLogicContracts
{
public interface IMessageInfoLogic
{
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
bool Create(MessageInfoBindingModel model);
}
}

View File

@ -1,12 +1,12 @@
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.ViewModels;
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautySalonContracts.BusinessLogicsContracts
namespace BeautyStudioContracts.BusinessLogicContracts
{
public interface IReportLogic
{

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.SearchModels
{
public class MessageInfoSearchModel
{
public int? StorekeeperId { get; set; }
public string? MessageId { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.StoragesContracts
{
public interface IMessageInfoStorage
{
List<MessageInfoViewModel> GetFullList();
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
}
}

View File

@ -22,7 +22,7 @@ namespace BeautyStudioContracts.ViewModels
public int LaborCostId { get; set; }
public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
public List<CosmeticProcedureViewModel> CosmeticProcedure { get; set; } = new();
//public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
public Dictionary<int, IProcedureModel> CosmeticProcedure { get; set; } = new();
}
}

View File

@ -0,0 +1,30 @@
using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
public class MessageInfoViewModel : IMessageInfoModel
{
public string MessageId { get; set; } = string.Empty;
[DisplayName("Отправитель")]
public int? StorekeeperId { get; set; }
[DisplayName("Получатель")]
public string SenderName { get; set; } = string.Empty;
[DisplayName("Дата письма")]
public DateTime DateDelivery { get; set; }
[DisplayName("Заголовок")]
public string Subject { get; set; } = string.Empty;
[DisplayName("Текст")]
public string Body { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
public class ReportCosmeticProceduresViewModel
{
public string CosmeticName { get; set; } = string.Empty;
public List<string> Procedures { get; set; } = new();
}
}

View File

@ -0,0 +1,22 @@
using BeautyStudioDataModels.Enums;
using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
public class ReportOrdersViewModel
{
public int Id { get; set; }
public DateTime DateCreate { get; set; }
public double OrderAmount { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public Dictionary<int, (ICosmeticModel, int)> Cosmetics { get; set; } = new();
public Dictionary<int, (IProcedureModel, int)> Procedures { get; set; } = new();
public Dictionary<int, (IServiceModel, int)> Services { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
public class ReportProcedureCosmeticsViewModel
{
public string ProcedureName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Cosmetic, int Count)> Cosmetics { get; set; } = new();
}
}

View File

@ -0,0 +1,20 @@
using BeautyStudioContracts.ViewModels;
using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioContracts.ViewModels
{
public class ReportServicesViewModel
{
public int Id { get; set; }
public string ServiceName { get; set; } = string.Empty;
public Dictionary <int, (ICosmeticModel, int)> Cosmetics { get; set; } = new();
public Dictionary <int, (IProcedureModel, int)> Procedures { get; set; } = new();
public double ServicePrice { get; set; }
}
}

View File

@ -20,8 +20,8 @@ namespace BeautyStudioContracts.ViewModels
[DisplayName("Сотрудник")]
public int StoreKeeperId { get; set; }
public List<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
public List<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
public Dictionary<ServiceCosmeticViewModel> ServiceCosmetic { get; set; } = new();
public Dictionary<ServiceProcedureViewModel> ServiceProcedure { get; set; } = new();
public List<OrderServiceViewModel> OrderService { get; set; } = new();
}
}

View File

@ -11,5 +11,6 @@ namespace BeautyStudioDataModels.Models
string CosmeticName { get; }
double CosmeticPrice { get; }
int LaborCostId { get; }
Dictionary<int, IProcedureModel> CosmeticProcedure { get; }
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioDataModels.Models
{
public interface IMessageInfoModel
{
string MessageId { get; }
string SenderName { get; }
DateTime DateDelivery { get; }
string Subject { get; }
string Body { get; }
}
}

View File

@ -15,6 +15,9 @@ namespace BeautyStudioDataModels.Models
OrderStatus Status { get; }
int ServiceId { get; }
int CosmeticId { get; }
Dictionary<int, (ICosmeticModel, int)> OrderCosmetic { get; }
Dictionary<int, (IProcedureModel, int)> OrderProcedureCosmetic { get; }
Dictionary<int, (IServiceModel, int)> OrderService { get; }
}
}

View File

@ -11,5 +11,6 @@ namespace BeautyStudioDataModels.Models
string ProcedureName { get; }
double ProcedureCost { get; }
string ProcedureDescription { get; }
Dictionary<int, (ICosmeticModel, int)> ProcedureCosmetics { get; }
}
}

View File

@ -12,5 +12,7 @@ namespace BeautyStudioDataModels.Models
string ServiceName { get; }
double ServicePrice { get; }
int StoreKeeperId { get; set; }
Dictionary<int, (ICosmeticModel, int)> ServiceCosmetic { get; }
Dictionary<int, (IProcedureModel, int)> ServiceProcedure { get; }
}
}

View File

@ -27,5 +27,6 @@ namespace BeautyStudioDatabaseImplement
public virtual DbSet<OrderProcedure> OrderProcedures { set; get; }
public virtual DbSet<CosmeticProcedure> CosmeticProcedures { set; get; }
public virtual DbSet<StoreKeeper> StoreKeepers { set; get; }
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
}
}

View File

@ -0,0 +1,58 @@
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.StoragesContracts;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Implements
{
public class MessageInfoStorage : IMessageInfoStorage
{
public List<MessageInfoViewModel> GetFullList()
{
using var context = new BeautyStudioDatabase();
return context.MessageInfos.Select(x => x.GetViewModel).ToList();
}
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
{
if (!model.StorekeeperId.HasValue)
{
return new List<MessageInfoViewModel>();
}
using var context = new BeautyStudioDatabase();
return context.MessageInfos
.Where(x => x.StorekeeperId == model.StorekeeperId && x.StorekeeperId == model.StorekeeperId)
.Select(x => x.GetViewModel)
.ToList();
}
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
{
if (string.IsNullOrEmpty(model.MessageId))
{
return new();
}
using var context = new BeautyStudioDatabase();
return context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
}
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
{
var newMessage = MessageInfo.Create(model);
if (newMessage == null)
{
return null;
}
using var context = new BeautyStudioDatabase();
context.MessageInfos.Add(newMessage);
context.SaveChanges();
return newMessage.GetViewModel;
}
}
}

View File

@ -28,9 +28,10 @@ namespace BeautyStudioDatabaseImplement.Models
public int LaborCostId { get; set; }
public virtual LaborCost LaborCost { get; set; } = new();
// связь многие-ко-многим заказов и косметики
[ForeignKey("CosmeticId")]
public virtual List<OrderCosmetic> Orders { get; set; } = new();
//// связь многие-ко-многим заказов и косметики
//[ForeignKey("CosmeticId")]
//public virtual List<OrderCosmetic> Orders { get; set; } = new();
// связь многие-ко-многим косметики с процедурами
[ForeignKey("CosmeticId")]
public virtual List<CosmeticProcedure> Procedures { get; set; } = new();

View File

@ -0,0 +1,65 @@
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.ViewModels;
using BeautyStudioDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeautyStudioDatabaseImplement.Models
{
public class MessageInfo : IMessageInfoModel
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.None)]
public string MessageId { get; set; } = string.Empty;
public int? StorekeeperId { get; set; }
public virtual StoreKeeper? Storekeeper { get; set; }
[Required]
public string SenderName { get; set; } = string.Empty;
[Required]
public DateTime DateDelivery { get; set; }
[Required]
public string Subject { get; set; } = string.Empty;
[Required]
public string Body { get; set; } = string.Empty;
public static MessageInfo? Create(MessageInfoBindingModel? model)
{
if (model == null)
{
return null;
}
return new()
{
MessageId = model.MessageId,
StorekeeperId = model.StorekeeperId,
SenderName = model.SenderName,
DateDelivery = model.DateDelivery,
Subject = model.Subject,
Body = model.Body,
};
}
public MessageInfoViewModel GetViewModel => new()
{
MessageId = MessageId,
StorekeeperId = StorekeeperId,
SenderName = SenderName,
DateDelivery = DateDelivery,
Subject = Subject,
Body = Body
};
}
}

View File

@ -25,10 +25,6 @@ namespace BeautyStudioDatabaseImplement.Models
[Required]
public string StoreKeeperPhone { get; set; } = string.Empty;
//связь один-ко-многим кладовщика с косметикой
[ForeignKey("StoreKeeperId")]
public virtual List<Cosmetic> Cosmetics { get; set; } = new();
public static StoreKeeper? Create(StoreKeeperBindingModel model)
{

View File

@ -19,7 +19,6 @@
<ProjectReference Include="..\BeautyStudioBusinessLogic\BeautyStudioBusinessLogic.csproj" />
<ProjectReference Include="..\BeautyStudioContracts\BeautyStudioContracts.csproj" />
<ProjectReference Include="..\BeautyStudioDatabaseImplement\BeautyStudioDatabaseImplement.csproj" />
<ProjectReference Include="..\BeautyStudioDataModels\BeautyStudioDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeautyStudioRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeautyStudioRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeautyStudioRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeutySalonClientApp.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -3,34 +3,32 @@ using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.BusinessLogicContracts;
using Microsoft.AspNetCore.Mvc;
namespace HotelRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ReportController : Controller
{
private readonly ILogger _logger;
private readonly IReportStoreKeeperLogic _reportStoreKeeperLogic;
private readonly AbstractMailWorker _mailWorker;
private readonly IReportLogic _reportLogic;
public ReportController(ILogger<ReportController> logger, IReportStoreKeeperLogic reportStoreKeeperLogic, AbstractMailWorker mailWorker)
private readonly AbstractMailWorker _mailWorker;
public ReportController(ILogger<ReportController> logger, IReportLogic reportLogic, AbstractMailWorker abstractMailWorker)
{
_logger = logger;
_reportStoreKeeperLogic = reportStoreKeeperLogic;
_mailWorker = mailWorker;
_reportLogic = reportLogic;
_mailWorker = abstractMailWorker;
}
[HttpPost]
public void CreateStoreKeeperReportToPdfFile(ReportStoreKeeperBindingModel model)
public void SaveServicesPdfFile(ReportBindingModel report)
{
try
{
_reportStoreKeeperLogic.SaveClientsToPdfFile(new ReportStoreKeeperBindingModel
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
{
DateFrom = model.DateFrom,
DateTo = model.DateTo,
StoreKeeperId = model.StoreKeeperId,
FileName = "C:\\Reports\\pdffile.pdf",
DateFrom = report.DateFrom,
DateTo = report.DateTo,
FileName = "C:\\reports\\pdfservicesreport.pdf",
});
}
catch (Exception ex)
@ -39,13 +37,51 @@ namespace HotelRestApi.Controllers
throw;
}
}
[HttpPost]
public void SendPdfToMail(MailSendInfoBindingModel model)
public void SaveCosmeticProceduresToWordFile(ReportBindingModel report)
{
try
{
_mailWorker.MailSendAsync(model);
_reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel { FileName = "C:\\reports\\wordcosmeticproceduresreport.docx" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void SaveCosmeticProceduresToExcelFile(ReportBindingModel report)
{
try
{
_reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel { FileName = "C:\\reports\\excelcosmeticproceduresreport.xlsx" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void MailSend(ReportServiceBindingModel report)
{
try
{
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
{
DateFrom = report.DateFrom,
DateTo = report.DateTo,
FileName = report.FileName,
StorekeeperId = report.StorekeeperId,
Email = report.Email,
});
_mailWorker.MailSendAsync(new MailSendInfoBindingModel
{
MailAddress = report.Email!,
Subject = "Отчет по услугам",
Text = "Ваш отчет:"
});
}
catch (Exception ex)
{
@ -53,81 +89,5 @@ namespace HotelRestApi.Controllers
throw;
}
}
[HttpPost]
public void CreateStoreKeeperReportToWordFile(ReportStoreKeeperBindingModel model)
{
try
{
_reportStoreKeeperLogic.SaveClientHearingToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateOrganiserReportToExcelFile(ReportStoreKeeperBindingModel model)
{
try
{
_reportStoreKeeperLogic.SaveClientHearingToExcelFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
/*[HttpPost]
public void CreateHeadwaiterReportToWordFile(ReportHeadwaiterBindingModel model)
{
try
{
_reportHeadwaiterLogic.SaveLunchRoomToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateHeadwaiterReportToExcelFile(ReportHeadwaiterBindingModel model)
{
try
{
_reportHeadwaiterLogic.SaveLunchRoomToExcelFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateHeadwaiterReportToPdfFile(ReportHeadwaiterBindingModel model)
{
try
{
_reportHeadwaiterLogic.SaveLunchesToPdfFile(new ReportHeadwaiterBindingModel
{
FileName = "C:\\Reports\\pdffile.pdf",
DateFrom = model.DateFrom,
DateTo = model.DateTo,
HeadwaiterId = model.HeadwaiterId,
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}*/
}
}

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeautyStudioRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -4,7 +4,7 @@ using BeautyStudioContracts.SearchModels;
using BeautyStudioContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeautyStudioRestApi.Controllers
namespace BeautyStudioRestAPI.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]

View File

@ -1,4 +1,4 @@
using BeautyStudioBusinessLogic.BusinessLogics;
using BeautyStudioBusinessLogic.BusinessLogic;
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioContracts.StoragesContracts;
@ -7,9 +7,7 @@ using BeautyStudioBusinessLogic.OfficePackage;
using BeautyStudioBusinessLogic.OfficePackage.Implements;
using Microsoft.OpenApi.Models;
using System.Reflection.PortableExecutable;
using BeautyStudioBusinesLogics.OfficePackage;
using BeautyStudioBusinesLogic.OfficePackage.Implements;
using BeautyStudioBusinesLogic.OfficePackage;
using BeautyStudioBusinessLogic.MailWorker;
var builder = WebApplication.CreateBuilder(args);
@ -32,11 +30,16 @@ builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
builder.Services.AddTransient<ILaborCostLogic, LaborCostLogic>();
builder.Services.AddTransient<ICosmeticLogic, CosmeticLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractMailWorker, MailKitWorker>();
builder.Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
builder.Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
builder.Services.AddControllers();
@ -44,16 +47,25 @@ builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BeautyStudioRestApi", Version = "v1" });
c.SwaggerDoc("v1", new OpenApiInfo { Title = "BeautyStudioRestAPI", Version = "v1" });
});
var app = builder.Build();
var mailSender = app.Services.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
});
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BeautyStudioRestApi v1"));
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BeautyStudioRestAPI v1"));
}
app.UseAuthorization();

View File

@ -9,7 +9,7 @@
}
},
"profiles": {
"BeautyStudioRestApi": {
"BeautyStudioRestAPI": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,

View File

@ -5,11 +5,5 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"SmtpClientHost": "smtp.gmail.com",
"SmtpClientPort": "587",
"PopHost": "pop.gmail.com",
"PopPort": "995",
"MailLogin": "rpplabs724@gmail.com",
"MailPassword": "pyen krno ssaj rlvm"
"AllowedHosts": "*"
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="c:/temp/BeautyStudioRestApi.log" />
<file value="c:/temp/BeautyStudioRestAPI.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />

View File

@ -0,0 +1,49 @@
using BeautyStudioContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace StoreKeeperWebApp
{
public class APIStoreKeeper
{
private static readonly HttpClient _storekeeper = new();
public static StoreKeeperViewModel? Storekeeper { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_storekeeper.BaseAddress = new Uri(configuration["IPAddress"]);
_storekeeper.DefaultRequestHeaders.Accept.Clear();
_storekeeper.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _storekeeper.GetAsync(requestUrl);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
public static void PostRequest<T>(string requestUrl, T model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _storekeeper.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -1,27 +1,264 @@
using BeautyStudioContracts.BindingModels;
using BeautyStudioContracts.ViewModels;
using StoreKeeperWebApp;
using Microsoft.AspNetCore.Mvc;
using StoreKeeperWebApp.Models;
using System.Diagnostics;
using BeautyStudioContracts.BusinessLogicContracts;
using BeautyStudioBusinessLogic.MailWorker;
using DocumentFormat.OpenXml.Spreadsheet;
using Microsoft.Extensions.Hosting;
using BeautyStudioContracts.SearchModels;
using StoreKeeperWebApp.Models;
using Microsoft.AspNetCore.Identity.Data;
namespace StoreKeeperWebApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly ILogger _logger;
private readonly IStoreKeeperLogic _logic;
private readonly ICosmeticLogic _cosmeticLogic;
private readonly IReportLogic _reportLogic;
public HomeController(ILogger<HomeController> logger)
private readonly AbstractMailWorker _mailLogic;
public HomeController(ILogger<HomeController> logger, IStoreKeeperLogic workerLogic, ICosmeticLogic cosmeticLogic, IReportLogic reportLogic, AbstractMailWorker mailLogic)
{
_logger = logger;
_logic = workerLogic;
_cosmeticLogic = cosmeticLogic;
_reportLogic = reportLogic;
_mailLogic = mailLogic;
}
[HttpGet]
public IActionResult Index()
{
return View();
if (APIStoreKeeper.Storekeeper == null)
{
return Redirect("~/Home/Enter");
}
return View(APIStoreKeeper.Storekeeper);
}
[HttpGet]
public IActionResult Privacy()
{
if (APIStoreKeeper.Storekeeper == null)
{
return Redirect("~/Home/Enter");
}
return View(APIStoreKeeper.Storekeeper);
}
[HttpPost]
public void Privacy(string login, string password, string fio, string phone)
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè?... Ñþäà âõîä òîëüêî àâòîðèçîâàííûì, ëèáî óõîäè îòñþäà!!!");
}
if (string.IsNullOrEmpty(login) ||
string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
{
throw new Exception("Ââåäèòå ëîãèí, ïàðîëü, ÔÈÎ è òåëåôîí");
}
_logic.Update(new StoreKeeperBindingModel
{
Id = APIStoreKeeper.Storekeeper.Id,
StoreKeeperFIO = fio,
StoreKeeperLogin = login,
StoreKeeperPassword = password,
StoreKeeperEmail = login,
StoreKeeperPhone = phone
});
APIStoreKeeper.Storekeeper.StoreKeeperFIO = fio;
APIStoreKeeper.Storekeeper.StoreKeeperLogin = login;
APIStoreKeeper.Storekeeper.StoreKeeperPassword = password;
APIStoreKeeper.Storekeeper.StoreKeeperEmail = login;
APIStoreKeeper.Storekeeper.StoreKeeperPhone = phone;
Response.Redirect("Privacy");
}
[HttpGet]
public IActionResult Enter()
{
if (APIStoreKeeper.Storekeeper != null)
{
throw new Exception("Âû óæå àâòîðèçîâàëèñü!");
}
return View();
}
[HttpPost]
public void Enter(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Ââåäåíû íå âñå äàííûå!");
}
APIStoreKeeper.Storekeeper = _logic.ReadElement(new StoreKeeperSearchModel
{
StoreKeeperEmail = login,
StoreKeeperPassword = password
});
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Íåâåðíûé ëîãèí/ïàðîëü");
}
Response.Redirect("Index");
}
[HttpGet]
public IActionResult Register()
{
if (APIStoreKeeper.Storekeeper != null)
{
throw new Exception("Âû óæå çàðåãèñòðèðîâàëèñü!");
}
return View();
}
[HttpPost]
public void Register(string fullname, string email, string password, string phone)
{
if (string.IsNullOrEmpty(fullname) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(phone))
{
throw new Exception("Ââåäåíû íå âñå äàííûå!");
}
_logic.Create(new StoreKeeperBindingModel
{
StoreKeeperFIO = fullname,
StoreKeeperEmail = email,
StoreKeeperPassword = password,
StoreKeeperLogin = email,
StoreKeeperPhone = phone
});
Response.Redirect("Enter");
}
[HttpGet]
public void Logout()
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
}
APIStoreKeeper.Storekeeper = null;
Response.Redirect("Enter");
}
[HttpGet]
public IActionResult Reports()
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
}
var data = _reportLogic.GetServices(new ReportServiceBindingModel());
return View(data);
}
[HttpPost]
public async Task<IActionResult> CreateReportWord(List<int> cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
{
// Ïðîâåðêè ââîäà è àâòîðèçàöèè
var folderName = "C:\\îò÷åòû";
var fileName = $"Ñïèñîê ïðîöåäóð {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.docx";
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
_reportLogic.SaveCosmeticProceduresToWordFile(new ReportBindingModel
{
FileName = filePath,
DateFrom = dateFrom,
DateTo = dateTo
});
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
return File(fileBytes, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", fileName);
}
[HttpPost]
public async Task<IActionResult> CreateReportExcel(List<int> cosmetics, DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
{
// Ïðîâåðêè ââîäà è àâòîðèçàöèè
var folderName = "C:\\îò÷åòû";
var fileName = $"Ñïèñîê ïðîöåäóð {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.xlsx";
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
_reportLogic.SaveCosmeticProceduresToExcelFile(new ReportBindingModel
{
FileName = filePath,
DateFrom = dateFrom,
DateTo = dateTo
});
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
return File(fileBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName);
}
[HttpPost]
public async Task<IActionResult> CreateReportPdf(DateTime dateFrom, DateTime dateTo, [FromServices] IWebHostEnvironment hostingEnvironment)
{
// Ïðîâåðêè àâòîðèçàöèè è ââîäà
var folderName = "C:\\îò÷åòû";
var fileName = $"Ñïèñîê óñëóã {DateTime.Now.ToString("dd-MM-yyyy HH-mm-ss")}.pdf";
var filePath = Path.Combine(hostingEnvironment.ContentRootPath, folderName, fileName);
_reportLogic.SaveServicesToPdfFile(new ReportServiceBindingModel
{
FileName = filePath,
StorekeeperId = APIStoreKeeper.Storekeeper.Id
});
// Âîçâðàùàåì ôàéë äëÿ çàãðóçêè
var fileBytes = await System.IO.File.ReadAllBytesAsync(filePath);
return File(fileBytes, "application/pdf", fileName);
}
[HttpPost]
public async Task<IActionResult> SendReport(IFormFile fileUpload, [FromServices] IWebHostEnvironment hostingEnvironment)
{
if (APIStoreKeeper.Storekeeper == null)
{
throw new Exception("Íåîáõîäèìî àâòîðèçîâàòüñÿ!");
}
if (fileUpload == null || fileUpload.Length <= 0)
{
throw new Exception("Ôàéë íå âûáðàí èëè ïóñò!");
}
// Ïóòü äî ôàéëà
var uploadPath = Path.Combine(hostingEnvironment.ContentRootPath, "C:\\îò÷åòû");
var fileName = Path.GetFileName(fileUpload.FileName);
var fullPath = Path.Combine(uploadPath, fileName);
using (var fileStream = new FileStream(fullPath, FileMode.Create))
{
await fileUpload.CopyToAsync(fileStream);
}
_mailLogic.MailSendAsync(new MailSendInfoBindingModel
{
MailAddress = APIStoreKeeper.Storekeeper.StoreKeeperEmail,
Subject = $"{fileName.Split('.')[0]}",
Text = $"Îò÷¸ò îòïðàâëåí {DateTime.Now}",
Path = fullPath
});
return RedirectToAction("Reports", "Home");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
@ -29,4 +266,4 @@ namespace StoreKeeperWebApp.Controllers
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
}

View File

@ -6,6 +6,12 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="MailKit" Version="4.6.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BeautyStudioBusinessLogic\BeautyStudioBusinessLogic.csproj" />
<ProjectReference Include="..\BeautyStudioContracts\BeautyStudioContracts.csproj" />

View File

@ -0,0 +1,29 @@
@using BeautyStudioContracts.ViewModels
@model LaborCostViewModel
@{
ViewData["Title"] = "Редактирование трудозатраты";
}
<div class="text-center">
<h2 class="display-4">Редактирование трудозатрат</h2>
</div>
<form method="post" style="margin-top: 50px">
<div class="row">
<div class="col-4">Потрачено времени (часов):</div>
<div class="col-8"><input type="text" name="hours" value="@Model.TimeSpent" /></div>
</div>
<div class="row">
<div class="col-4">Сложность:</div>
<div class="col-8"><input type="text" name="difficulty" value="@Model.Difficulty" /></div>
</div>
<!-- Кнопка "Сохранить" -->
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -6,7 +6,7 @@
<title>@ViewData["Title"] - StoreKeeperApp</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/BeutySalonStaffMemberApp.styles.css" asp-append-version="true" />
<link rel="stylesheet" href="~/BeautyStudioStaffMemberApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
@ -29,13 +29,13 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Авторизация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Service">Услуги</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Service" asp-action="Service">Услуги</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="LaborCosts">Трудозатраты</a>
<a class="nav-link text-dark" asp-area="" asp-controller="LaborCosts" asp-action="LaborCosts">Трудозатраты</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Cosmetic">Косметика</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Cosmetic" asp-action="Cosmetic">Косметика</a>
</li>
</ul>
</div>

View File

@ -5,5 +5,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"SmtpClientHost": "smtp.gmail.com",
"SmtpClientPort": "587",
"PopHost": "pop.gmail.com",
"PopPort": "995",
"MailLogin": "rpplabs724@gmail.com",
"MailPassword": "tdqp zkqz avzv yebn"
}