public IActionResult Get(Guid id) { try { using (var db = new AllInOneContext.AllInOneContext()) { InstitutionsDutyCheckSchedule data = db.InstitutionsDutyCheckSchedule //.Include(t => t.Entourages) .Include(t => t.InspectedOrganization) //.Include(t=>t.InspectionTarget) .Include(t => t.Lead) .FirstOrDefault(p => p.InstitutionsDutyCheckScheduleId.Equals(id)); if (data == null) { return(NoContent()); } return(new ObjectResult(data)); } } catch (Exception ex) { return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public IActionResult Update([FromBody] InstitutionsDutyCheckSchedule model) { try { if (model == null) { return(BadRequest()); } using (var db = new AllInOneContext.AllInOneContext()) { db.InstitutionsDutyCheckSchedule.Update(model); db.SaveChanges(); return(new NoContentResult()); } } catch (DbUpdateException dbEx) { return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (System.Exception ex) { return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }
public IActionResult Delete(Guid id) { try { using (var db = new AllInOneContext.AllInOneContext()) { InstitutionsDutyCheckSchedule data = db.InstitutionsDutyCheckSchedule.FirstOrDefault(p => p.InstitutionsDutyCheckScheduleId == id); if (data == null) { return(NoContent()); } db.InstitutionsDutyCheckSchedule.Remove(data); db.SaveChanges(); return(new NoContentResult()); } } catch (System.Exception ex) { return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } }