/// <summary>
 /// Сохранение покупок в файл-Excel
 /// </summary>
 /// <param name="model"></param>
 public void SavePurchaseListToExcelFile(ReportBindingModelEmployee model)
 {
     SaveToExcelEmployee.CreateDoc(new ExcelInfoEmployee
     {
         FileName  = model.FileName,
         Title     = "Сведения по покупкам",
         Purchases = GetPurchaseList(model)
     });
 }
 /// <summary>
 /// Сохранение косметики в файл-Pdf
 /// </summary>
 /// <param name="model"></param>
 public void SaveCosmeticsToPdfFile(ReportBindingModelEmployee model)
 {
     SaveToPdfEmployee.CreateDoc(new PdfInfoEmployee
     {
         FileName   = model.FileName,
         Title      = "Список косметики",
         DateFrom   = model.DateFrom.Value,
         DateTo     = model.DateTo.Value,
         EmployeeId = model.EmployeeId.Value,
         Cosmetics  = GetCosmetics(model)
     });
 }
Beispiel #3
0
        public List <Tuple <string, int> > GetDistributionStatistic(ReportBindingModelEmployee model)
        {
            var list = new List <ReportCosmeticsViewModel>();

            if (model.EmployeeId != 0)
            {
                list = _statisticStorage.GetDistributions(model);
            }
            else
            {
                list = _statisticStorage.GetDistributionsForAll(model);
            }
            return(list.OrderBy(rec => rec.CosmeticName).GroupBy(rec => new { rec.CosmeticName, rec.Count }).Select(rec => new Tuple <string, int>(rec.Key.CosmeticName, rec.Key.Count)).ToList());
        }
        /// <summary>
        /// Получение списка покупок по выбранной косметике
        /// </summary>
        /// <returns></returns>
        public List <ReportPurchaseCosmeticViewModel> GetPurchaseList(ReportBindingModelEmployee model)
        {
            var     list      = new List <ReportPurchaseCosmeticViewModel>();
            decimal totalCost = 0;

            foreach (var cosmetic in model.purchaseCosmetics)
            {
                list.AddRange(_reportStorage.GetPurchaseList(cosmetic));
            }

            foreach (var reportPurchaseCosmetic in list)
            {
                totalCost += reportPurchaseCosmetic.Price * reportPurchaseCosmetic.Count;
            }

            list[0].TotalCost = totalCost;
            return(list);
        }
 public List <ReportCosmeticsViewModel> GetReceiptsForAll(ReportBindingModelEmployee model)
 {
     using (var context = new BeautySaloonDatabase())
     {
         return((
                    from c in context.Cosmetics
                    join rc in context.ReceiptCosmetics on c.Id equals rc.CosmeticId
                    join r in context.Receipts on rc.ReceiptId equals r.Id
                    where r.PurchaseDate >= model.DateFrom
                    where r.PurchaseDate <= model.DateTo
                    select new ReportCosmeticsViewModel
         {
             TypeOfService = "Чек",
             DateOfService = r.PurchaseDate,
             CosmeticName = c.CosmeticName,
             Count = rc.Count
         })
                .ToList());
     }
 }
 public List <ReportCosmeticsViewModel> GetDistributionsForAll(ReportBindingModelEmployee model)
 {
     using (var context = new BeautySaloonDatabase())
     {
         return((
                    from c in context.Cosmetics
                    join dc in context.DistributionCosmetics on c.Id equals dc.CosmeticId
                    join d in context.Distributions on dc.DistributionId equals d.Id
                    where d.IssueDate >= model.DateFrom
                    where d.IssueDate <= model.DateTo
                    select new ReportCosmeticsViewModel
         {
             TypeOfService = "Выдача",
             DateOfService = d.IssueDate,
             CosmeticName = c.CosmeticName,
             Count = dc.Count
         })
                .ToList());
     }
 }
 public List <ReportCosmeticsViewModel> GetCosmetics(ReportBindingModelEmployee model)
 {
     using (var context = new BeautySaloonDatabase())
     {
         return((
                    from c in context.Cosmetics
                    join rc in context.ReceiptCosmetics on c.Id equals rc.CosmeticId
                    join r in context.Receipts on rc.ReceiptId equals r.Id
                    where r.EmployeeId == model.EmployeeId
                    where r.PurchaseDate >= model.DateFrom
                    where r.PurchaseDate <= model.DateTo
                    select new ReportCosmeticsViewModel
         {
             TypeOfService = "Чек",
             DateOfService = r.PurchaseDate,
             CosmeticName = c.CosmeticName,
             Count = rc.Count
         })
                .Union(
                    from c in context.Cosmetics
                    join dc in context.DistributionCosmetics on c.Id equals dc.CosmeticId
                    join d in context.Distributions on dc.DistributionId equals d.Id
                    where d.EmployeeId == model.EmployeeId
                    where d.IssueDate >= model.DateFrom
                    where d.IssueDate <= model.DateTo
                    select new ReportCosmeticsViewModel
         {
             TypeOfService = "Выдача",
             DateOfService = d.IssueDate,
             CosmeticName = c.CosmeticName,
             Count = dc.Count
         })
                .OrderBy(x => x.DateOfService)
                .ToList());
     }
 }
 /// <summary>
 /// Получение списка косметики за определенный период
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <ReportCosmeticsViewModel> GetCosmetics(ReportBindingModelEmployee model)
 {
     return(_reportStorage.GetCosmetics(model));
 }