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)); }
/// <summary> /// Получение списка процедур за определенный период /// </summary> /// <param name="model"></param> /// <returns></returns> public List <ReportProceduresViewModel> GetProcedures(ReportBindingModelClient model) { var listAll = new List <ReportProceduresViewModel>(); var client = _clientStorage.GetElement(new ClientBindingModel { Id = model.ClientId }); var listPurchases = _purchaseStorage.GetFilteredList(new PurchaseBindingModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }); foreach (var purchase in listPurchases) { foreach (var pp in purchase.PurchaseProcedures) { listAll.Add(new ReportProceduresViewModel { TypeOfService = "Покупка", DateOfService = purchase.Date, ProcedureName = pp.Value.Item1, Price = pp.Value.Item2, }); } } var listVisits = _visitStorage.GetFilteredList(new VisitBindingModel { ClientId = model.ClientId, DateFrom = model.DateFrom, DateTo = model.DateTo }); foreach (var visit in listVisits) { foreach (var vp in visit.VisitProcedures) { listAll.Add(new ReportProceduresViewModel { TypeOfService = "Посещение", DateOfService = visit.Date, ProcedureName = vp.Value, }); } } return(listAll); }