示例#1
0
 public IActionResult Get(Guid id)
 {
     try
     {
         using (var db = new AllInOneContext.AllInOneContext())
         {
             TemporaryDuty data = db.TemporaryDuty
                                  .Include(t => t.Commander)
                                  .Include(t => t.DutyProgrammePicture)
                                  .Include(t => t.DutyType)
                                  .Include(t => t.Equipments)
                                  .Include(t => t.Organization)
                                  .Include(t => t.VehicleType)
                                  .FirstOrDefault(p => p.TemporaryDutyId.Equals(id));
             if (data == null)
             {
                 return(NoContent());
             }
             return(new ObjectResult(data));
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(new ApplicationException {
             ErrorCode = "Unknown", ErrorMessage = ex.Message
         }));
     }
 }
示例#2
0
 public IActionResult Update([FromBody] TemporaryDuty model)
 {
     try
     {
         if (model == null)
         {
             return(BadRequest());
         }
         using (var db = new AllInOneContext.AllInOneContext())
         {
             db.TemporaryDuty.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
         }));
     }
 }
示例#3
0
 public IActionResult Delete(Guid id)
 {
     try
     {
         using (var db = new AllInOneContext.AllInOneContext())
         {
             TemporaryDuty data = db.TemporaryDuty.FirstOrDefault(p => p.TemporaryDutyId == id);
             if (data == null)
             {
                 return(NoContent());
             }
             db.TemporaryDuty.Remove(data);
             db.SaveChanges();
             return(new NoContentResult());
         }
     }
     catch (System.Exception ex)
     {
         return(BadRequest(new ApplicationException {
             ErrorCode = "Unknown", ErrorMessage = ex.Message
         }));
     }
 }
        public ActionResult TemporaryDutyAdd(TemporaryDuty temporaryDuty)

        {
            _temporaryDutyService.Add(temporaryDuty);
            return(RedirectToAction(""));
        }
        public ActionResult TemporaryDutyUpdate(TemporaryDuty temporaryDuty)

        {
            _temporaryDutyService.Update(temporaryDuty);
            return(RedirectToAction(""));
        }
示例#6
0
 public IResult Update(TemporaryDuty temporaryDuty)
 {
     _temporaryDutyDal.Update(temporaryDuty);
     return(new SuccessResult());
 }
示例#7
0
 public IResult Delete(TemporaryDuty temporaryDuty)
 {
     throw new NotImplementedException();
 }