public void StockUpdate(PatientRecordModel medicineGiven) { PractitionerData data = new PractitionerData(); List <StockUpdate> stock = new List <StockUpdate>(); StockUpdate medicine = new StockUpdate(); if (medicineGiven.QuantityForMedicine1 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId1), Quantity = medicineGiven.QuantityForMedicine1, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine2 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId2), Quantity = medicineGiven.QuantityForMedicine2, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine3 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId3), Quantity = medicineGiven.QuantityForMedicine3, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine4 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId4), Quantity = medicineGiven.QuantityForMedicine4, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine5 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId5), Quantity = medicineGiven.QuantityForMedicine5, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine6 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId6), Quantity = medicineGiven.QuantityForMedicine6, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine7 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId7), Quantity = medicineGiven.QuantityForMedicine7, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine8 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId8), Quantity = medicineGiven.QuantityForMedicine8, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine9 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId9), Quantity = medicineGiven.QuantityForMedicine9, }; stock.Add(medicine); } if (medicineGiven.QuantityForMedicine10 > 0) { medicine = new StockUpdate() { MedicineId = Guid.Parse(medicineGiven.MedicinesId10), Quantity = medicineGiven.QuantityForMedicine10, }; stock.Add(medicine); } data.StockUpdate(stock, medicineGiven); }