Exemplo n.º 1
0
 public ActionResult Edit(long id)
 {
     var entity = MaintDbContext.SystemJobs.FirstOrDefault(x=>x.SystemJobId == id);
     if (entity == null )
     {
         return HttpNotFound();
     }
     var model = new SystemJobEditModel();
     model.FromEntity(entity, false, ControllerContext);
     return Template(model.CreateTemplate(ControllerContext));
 }
Exemplo n.º 2
0
 public async Task<ActionResult> Edit(SystemJobEditModel model, long id)
 {
     var entity = MaintDbContext.SystemJobs.FirstOrDefault(x => x.SystemJobId == id);
     if (entity == null /*TODO: check entity should be edit*/)
     {
         return HttpNotFound();
     }
     model.FromEntity(entity, true, ControllerContext);
     if (!TryUpdateModel(entity, model))
     {
         return Template(model.CreateTemplate(ControllerContext));
     }
     using (var trans = new TransactionScope())
     {
         await MaintDbContext.SaveChangesAsync();
         trans.Complete();
     }
     await SetFlashAsync(new FlashMessage
     {
         Text = MaintCultureTextResources.SuccessToSave,
         MessageType = FlashMessageType.Success,
     });
     return Template(model.CreateTemplate(ControllerContext));
 }