public ActionResult Edit(HR.Models.EvaluationElementCompetenies model) { try { if (ModelState.IsValid) { var flag = reposatoryEvaluationElementCompetenies.Editone(model); if (flag) { TempData["Message"] = HR.Resource.pers_2.addedSuccessfully; //=================================check for alert================================== var get_result_check = HR.Controllers.check.check_alert("evaluation elements competencies", 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(HR.Models.EvaluationElementCompetenies model) { try { context.EvaluationElementCompetenies.Add(model); context.SaveChanges(); return(true); } catch (DbUpdateException) { return(false); } catch (Exception) { return(false); } }
public bool Editone(HR.Models.EvaluationElementCompetenies model) { try { var record = context.EvaluationElementCompetenies.FirstOrDefault(m => m.ID == model.ID); record.Name = model.Name; record.Description = model.Description; 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 = reposatoryEvaluationElementCompetenies.GetAll(); var model = new HR.Models.EvaluationElementCompetenies(); 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")); } }