public static int RemovePatientLab(App_PatientLabs_Labs model) { using (var dbcontext = new HMSEntities()) { var parms = dbcontext.PatientLabs_Labs_Parms.Where(l => l.PatientLabId == model.PatientLabId && l.TestId == model.TestId).ToList(); var labs = dbcontext.PatientLabs_Labs.Where(l => l.PatientLabId == model.PatientLabId && l.TestId == model.TestId).ToList(); dbcontext.PatientLabs_Labs_Parms.RemoveRange(parms); dbcontext.SaveChanges(); dbcontext.PatientLabs_Labs.RemoveRange(labs); dbcontext.SaveChanges(); var totalFeeTillNow = dbcontext.PatientLabs_Labs.Where(o => o.PatientLabId == model.PatientLabId).ToList().Sum(o => o.Lab_Tests.Fee); var rec = dbcontext.PatientLabs.FirstOrDefault(p => p.Id == model.PatientLabId); rec.Amount = totalFeeTillNow; if (rec.Amount < rec.Discount) { rec.Discount = 0; rec.DiscountBy = ""; } dbcontext.SaveChanges(); return(totalFeeTillNow); } }
public JsonResult RemovePatientLab(App_PatientLabs_Labs model) { var fee = LabService.RemovePatientLab(model); return(Json(fee, JsonRequestBehavior.AllowGet)); }