public DrugModel PostReviewMethod(DrugModel model) { using (var drugr = new DrugRespo()) { if (model.DrugId == 0) { Drug _drug = new Drug { DrugId = model.DrugId, DrugCode = model.DrugCode, DrugName = model.DrugName, DrugCategory = model.DrugCategory, DrugDescription = model.DrugDescription, DrugQuantity = model.DrugQuantity, Status = model.Status, DrugPrice = model.DrugPrice, DrugType = model.DrugType, }; drugr.Insert(_drug); } else { //var _drug = drugr.GetById(dr.DrugId); Drug _drug = drugr.GetById(model.DrugId); _drug.DrugId = model.DrugId; _drug.DrugCode = model.DrugCode; _drug.DrugName = model.DrugName; _drug.DrugCategory = model.DrugCategory; _drug.DrugDescription = model.DrugDescription; _drug.DrugQuantity = model.DrugQuantity; _drug.Status = model.Status; _drug.DrugPrice = model.DrugPrice; _drug.DrugType = model.DrugType; drugr.Update(_drug); } return(model); } }
public void CreateMethod(DrugModel model, string DrugType) { DrugpropRepository dp = new DrugpropRepository(); using (var drugr = new DrugRespo()) { if (model.DrugId == 0) { Drug _drug = new Drug(); //_drug.DrugId = model.DrugId; _drug.DrugCode = model.DrugCode; _drug.DrugName = dp.GetById(model.DrugCode).DrugName + " (" + DrugType + ")"; _drug.DrugCategory = dp.GetById(model.DrugCode).DrugCategory; _drug.DrugDescription = dp.GetById(model.DrugCode).DrugDescription; _drug.DrugQuantity = model.DrugQuantity; _drug.Status = "Available"; _drug.DrugPrice = model.DrugPrice; _drug.DrugType = DrugType; _drug.DateCreated = DateTime.Now; drugr.Insert(_drug); } } }