예제 #1
0
 public IActionResult Update([FromBody] DailyOnDuty model)
 {
     try
     {
         if (model == null)
         {
             return(BadRequest());
         }
         using (var db = new AllInOneContext.AllInOneContext())
         {
             db.DailyOnDuty.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
         }));
     }
 }
예제 #2
0
        public IActionResult Get(Guid id)
        {
            using (var db = new AllInOneContext.AllInOneContext())
            {
                DailyOnDuty data = db.DailyOnDuty
                                   .Include(t => t.DutyOfficerToday).Include(t => t.Organization)
                                   .Include(t => t.Status).Include(t => t.TomorrowAttendant)
                                   .FirstOrDefault(p => p.DailyOnDutyId.Equals(id));
                if (data == null)
                {
                    return(NoContent());
                }

                return(new ObjectResult(data));
            }
        }
예제 #3
0
 public IActionResult Delete(Guid id)
 {
     try
     {
         using (var db = new AllInOneContext.AllInOneContext())
         {
             DailyOnDuty data = db.DailyOnDuty.FirstOrDefault(p => p.DailyOnDutyId.Equals(id));
             if (data == null)
             {
                 return(NoContent());
             }
             db.DailyOnDuty.Remove(data);
             db.SaveChanges();
             return(new NoContentResult());
         }
     }
     catch (System.Exception ex)
     {
         return(BadRequest(new ApplicationException {
             ErrorCode = "Unknown", ErrorMessage = ex.Message
         }));
     }
 }