Beispiel #1
0
 public List <ReceiptViewModel> Read(ReceiptBindingModel model)
 {
     if (model == null)
     {
         return(_receiptStorage.GetFullList());
     }
     if (model.Id.HasValue)
     {
         return(new List <ReceiptViewModel> {
             _receiptStorage.GetElement(model)
         });
     }
     return(_receiptStorage.GetFilteredList(model));
 }
        public void Linking(SymptomaticLinkingBindingModel model)
        {
            var symptomatic = _symptomaticStorage.GetElement(new SymptomaticsBindingModel
            {
                Id = model.SymptomaticId
            });

            var receipt = _receiptStorage.GetElement(new ReceiptBindingModel
            {
                Id = model.ReceiptId
            });

            if (symptomatic == null)
            {
                throw new Exception("Не найдена выдача");
            }

            if (receipt == null)
            {
                throw new Exception("Не найдено выписка");
            }

            _symptomaticStorage.Update(new SymptomaticsBindingModel
            {
                Id                  = symptomatic.Id,
                IssueDate           = symptomatic.IssueDate,
                Lungs               = symptomatic.Lungs,
                Liver               = symptomatic.Liver,
                Heart               = symptomatic.Heart,
                SymptomName         = symptomatic.SymptomName,
                SymptomaticDiseases = symptomatic.SymptomaticDiseases,
                DoctorId            = symptomatic.DoctorId,
                ReceiptId           = model.ReceiptId
            });
            _receiptStorage.Update(new ReceiptBindingModel
            {
                Id             = receipt.Id,
                Dose           = receipt.Dose,
                PerDose        = receipt.PerDose,
                SymptomaticsId = model.SymptomaticId,
                MedicineId     = receipt.MedicineId
            });
        }
        public void Linking(PurchaseLinkingBindingModel model)
        {
            var purchase = _purchaseStorage.GetElement(new PurchaseBindingModel
            {
                Id = model.PurchaseId
            });

            var receipt = _receiptStorage.GetElement(new ReceiptBindingModel
            {
                Id = model.ReceiptId
            });

            if (purchase == null)
            {
                throw new Exception("Не найдена покупка");
            }

            if (receipt == null)
            {
                throw new Exception("Не найден чек");
            }

            if (purchase.ReceiptId.HasValue)
            {
                throw new Exception("Данная покупка уже привязана к чеку");
            }

            _purchaseStorage.Update(new PurchaseBindingModel
            {
                Id    = purchase.Id,
                Date  = purchase.Date,
                Price = purchase.Price,
                PurchaseProcedures = purchase.PurchaseProcedures,
                ClientId           = purchase.ClientId,
                ReceiptId          = model.ReceiptId
            });
        }