Beispiel #1
0
 public JsonResult Edit(Candidate model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var user = CurrentUser;
             if (model.IsNew)
             {
                 if (_db.Candidates.Any(c => c.Passport == model.Passport))
                 {
                     throw new SimpleException("Failed to update. Another candidate with this passport number exists in this project.");
                 }
                 _db.Candidates.Add(model);
             }
             else
             {
                 _db.Entry(model).State = System.Data.EntityState.Modified;
             }
             var uLog = user.CreateLog(LogHelper.CanidateUpdate(model));
             _db.UserLogs.Add(uLog);
             var cLog = model.CreateLog(model.ChangeStatus, user);
             _db.CandidateLogs.Add(cLog);
             _db.SaveChanges();
         }
         catch (SimpleException ex)
         {
             AddModelError(ex);
         }
     }
     return(GetErrorMsgJSON());
 }