public IActionResult UpsertAllergyRecord(ah.Models.AHMS_Customer_AllergicHistory model, List <string> AllergicBodyPartList) { try { if (model.CustomerId == null || model.CustomerId == 0) { model.CustomerId = GetCurrentLoginUser.CustomerId; } if (model.RecMan.IsEmpty()) { model.RecMan = GetCurrentLoginUser.CustomerName; } model.AllergicBodyParts = string.Join(",", AllergicBodyPartList.Where(m => !string.IsNullOrWhiteSpace(m))); if (model.AllergicBodyParts.IsEmpty()) { throw new Exception("没有选择过敏部位"); } if (model.AllergicHistoryId == 0) { MainDbContext.Add(model); MainDbContext.SaveChanges(); } else { MainDbContext.Update(model); MainDbContext.SaveChanges(); } MainDbContext.Database.ExecuteSqlCommand($"exec sp_Update_Allergic {model.CustomerId}");//更新 } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return(AllergyRecord()); }
public IActionResult AllergyRecord(ah.Models.AHMS_Customer_AllergicHistory model = null) { ViewBag.AlleryRecords = GetAlleryRecords(); ViewBag.MyAllergics = MainDbContext.CHIS_Code_Customer_HealthInfo.FirstOrDefault(m => m.CustomerId == GetCurrentLoginUser.CustomerId).Allergic; return(View(nameof(AllergyRecord), model)); }