public ActionResult Edit(EvaluationObjectives model) { try { if (ModelState.IsValid) { var flag = reposatoryObjective.Editone(model); if (flag) { TempData["Message"] = HR.Resource.pers_2.addedSuccessfully; //=================================check for alert================================== var get_result_check = HR.Controllers.check.check_alert("evaluation objective", HR.Models.user.Action.edit, HR.Models.user.type_field.form); if (get_result_check != null) { var inbox = new Models.user.Alert_inbox { send_from_user_id = User.Identity.Name, send_to_user_id = get_result_check.send_to_ID_user, title = get_result_check.Subject, Subject = get_result_check.Message }; if (get_result_check.until != null) { if (get_result_check.until.Value.Year != 0001) { inbox.until = get_result_check.until; } } ApplicationDbContext dbcontext = new ApplicationDbContext(); dbcontext.Alert_inbox.Add(inbox); dbcontext.SaveChanges(); } //=================================================================================== return(RedirectToAction("index")); } else { TempData["Message"] = HR.Resource.pers_2.Faild; return(View(model)); } } else { TempData["Message"] = HR.Resource.pers_2.Faild; return(View(model)); } } catch (Exception) { TempData["Message"] = HR.Resource.pers_2.Faild; return(View(model)); } }
public bool AddOne(EvaluationObjectives model) { try { context.EvaluationObjectives.Add(model); context.SaveChanges(); return true; } catch (DbUpdateException) { return false; } catch (Exception) { return false; } }
public bool Editone(EvaluationObjectives model) { try { var record = context.EvaluationObjectives.FirstOrDefault(m => m.ID == model.ID); record.Description = model.Description; record.Name = model.Name; context.SaveChanges(); return true; } catch (DbUpdateException) { return false; } catch (Exception) { return false; } }
public ActionResult Create() { try { /////////create code/////// var stru = reposatorystructure.find(ChModels.Personnel).Structure_Code; var ALLList = reposatoryObjective.GetAll(); var model = new EvaluationObjectives(); if (ALLList.Count() == 0) { model.Code = stru + "1"; } else { model.Code = stru + (ALLList.LastOrDefault().ID + 1).ToString(); } return(View(model)); } catch (Exception) { return(RedirectToAction("Index")); } }