//[ValidateAntiForgeryToken] public JsonResult Create(TrainingProgramCommon hRMS_ProgramDetail) { HRMS_ProgramDetail obj = hRMS_ProgramDetail.ProDetail; if (obj.ToDate < obj.FromDate) { var msg = "ToDate must be greater than FromDate!"; return(Json(msg, JsonRequestBehavior.AllowGet)); } else { db.HRMS_ProgramDetail.Add(obj); db.SaveChanges(); ViewBag.msg = "Program Added Succesfully! Now Add Faculty!"; var ID = db.HRMS_ProgramDetail.Where(x => x.TrainingID == obj.TrainingID).Select(x => x.ID).FirstOrDefault(); //update in training request table (programFlag) HRMS_Training_Request_Application req = db.HRMS_Training_Request_Application.Find(obj.TrainingID); req.ProgramFlag = 1; //admin can only edit program detail db.Entry(req).State = EntityState.Modified; db.SaveChanges(); return(Json(ID, JsonRequestBehavior.AllowGet)); //return RedirectToAction("Index"); } }
public ActionResult Edit([Bind(Include = "ID,FacultyType,EMP_ID,External_Name,PAN_No,ServiceTaxNo,Qualification,Contact,Email,Remark,IsActive,Empty")] HRMS_Faculty_MS hRMS_Faculty_MS) { if (ModelState.IsValid) { if (hRMS_Faculty_MS.EMP_ID != null) { bool IsExist = db.HRMS_Faculty_MS.Any(x => (x.ID != hRMS_Faculty_MS.ID) && (x.EMP_ID == hRMS_Faculty_MS.EMP_ID)); if (!IsExist) { db.Entry(hRMS_Faculty_MS).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Data Successfully changed!"; return(View(hRMS_Faculty_MS)); } else { ViewBag.error = "Record Already Exist!"; return(View(hRMS_Faculty_MS)); } } else { db.Entry(hRMS_Faculty_MS).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Data Successfully changed!"; return(View(hRMS_Faculty_MS)); } } return(View(hRMS_Faculty_MS)); }
public ActionResult Edit(HRMS_Travel_Application hRMS_Travel_Application) { //ModelState.Remove("From_Date"); //var FromDate = db.HRMS_Travel_Application.Where(rec => rec.ID == hRMS_Travel_Application.ID).SingleOrDefault(); //hRMS_Travel_Application.From_Date = FromDate.From_Date; //ModelState.Remove("To_Date"); //hRMS_Travel_Application.From_Date = FromDate.To_Date; //db.Entry(FromDate).State = EntityState.Detached; //HRMS_Travel_Application hRMS_Travel_ = db.HRMS_Travel_Application.Find(hRMS_Travel_Application.ID); //hRMS_Travel_.Status = hRMS_Travel_Application.Status; //db.Entry(hRMS_Travel_Application).State = EntityState.Modified; //db.SaveChanges(); //ModelState.Clear(); //return RedirectToAction("Index"); if (ModelState.IsValid) { db.Entry(hRMS_Travel_Application).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); //} // ViewBag.emp_id = new SelectList(db.Accounts, "ID", "UserName", hRMS_Travel_Application.emp_id); //ViewBag.Approved_by = new SelectList(db.Accounts, "ID", "UserName", hRMS_Travel_Application.Approved_by); //ViewBag.Grade = new SelectList(db.HRMS_CATEGORY_GRADE, "Category_ID", "Category_Name", hRMS_Travel_Application.Grade); //ViewBag.Designation = new SelectList(db.HRMS_DESG_MS, "Desg_Id", "Desg_Name", hRMS_Travel_Application.Designation); //ViewBag.Travel_Purpose = new SelectList(db.HRMS_Travel_Purpose, "ID", "Name", hRMS_Travel_Application.Travel_Purpose); //ViewBag.Travel_Type = new SelectList(db.HRMS_Travel_type, "ID", "Short_Name", hRMS_Travel_Application.Travel_Type); //ViewBag.Travel_App_Type = new SelectList(db.HRMS_TravelMode_MS, "Mode_ID", "Mode_Type", hRMS_Travel_Application.Travel_App_Type); } return(RedirectToAction("Index")); }
/// <summary> /// Generic Delete method for the entities /// </summary> /// <param name="entityToDelete"></param> public virtual void Delete(TEntity entityToDelete) { if (Context.Entry(entityToDelete).State == EntityState.Detached) { DbSet.Attach(entityToDelete); } DbSet.Remove(entityToDelete); }
//approve public ActionResult Approve(long id) { HRMS_TrainingApproval obj = db.HRMS_TrainingApproval.Where(x => x.ID == id).FirstOrDefault(); obj.ApproveBy = Convert.ToInt64(Session["id"]); obj.ApproveDate = DateTime.Now; obj.Status = 2;//approved db.Entry(obj).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("RequestList", new { id = obj.Program_ID })); }
public ActionResult Edit([Bind(Include = "ID,Short_Name,Name,Description")] HRMS_Travel_type hRMS_Travel_type) { if (ModelState.IsValid) { HRMS_Travel_type short_typealready = db.HRMS_Travel_type.Where(rec => rec.Short_Name == hRMS_Travel_type.Short_Name && rec.ID != hRMS_Travel_type.ID).FirstOrDefault(); if (short_typealready == null) { HRMS_Travel_type type_name_already = db.HRMS_Travel_type.Where(rec => rec.Name == hRMS_Travel_type.Name && rec.ID != hRMS_Travel_type.ID).FirstOrDefault(); if (type_name_already == null) { db.Entry(hRMS_Travel_type).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); } else { ViewBag.TypeStatus = "The name is already exist in another travel type!"; return(View()); } } else { ViewBag.TypeStatus = "The short name is already exist in another travel type!"; return(View()); } } return(View(hRMS_Travel_type)); }
public ActionResult Edit([Bind(Include = "Skill_ID,Skill_Name,Skill_Remark")] HRMS_TRAINING_SKILL_MS hRMS_TRAINING_SKILL_MS) { if (ModelState.IsValid) { ViewBag.Status = ""; var existData = db.HRMS_TRAINING_SKILL_MS.FirstOrDefault(rec => rec.Skill_Name == hRMS_TRAINING_SKILL_MS.Skill_Name && rec.Skill_Remark == hRMS_TRAINING_SKILL_MS.Skill_Remark && rec.Skill_Remark == hRMS_TRAINING_SKILL_MS.Skill_Remark && rec.Skill_ID != hRMS_TRAINING_SKILL_MS.Skill_ID); if (existData == null) { //var ExistRemark = db.HRMS_TRAINING_SKILL_MS.FirstOrDefault(rec => rec.Skill_Remark == hRMS_TRAINING_SKILL_MS.Skill_Remark && rec.Skill_ID != hRMS_TRAINING_SKILL_MS.Skill_ID); //if (ExistRemark == null) //{ db.Entry(hRMS_TRAINING_SKILL_MS).State = EntityState.Modified; db.SaveChanges(); //ModelState.Clear(); ViewBag.Status = "Skill Updateded succcessfully."; return(View()); //} //ViewBag.Status = "This Remark is Already Exist ! "; //return View(); } ViewBag.Status = "this Skill is already exist !"; return(View()); } return(View(hRMS_TRAINING_SKILL_MS)); }
public ActionResult Edit([Bind(Include = "ReligionID,ReligionShortName,ReligionName")] ReligionMaster religionMaster) { if (ModelState.IsValid) { bool isValid = db.ReligionMaster.Any(x => (x.ReligionID != religionMaster.ReligionID) && (x.ReligionShortName == religionMaster.ReligionShortName || x.ReligionName == religionMaster.ReligionName)); if (!isValid) { db.Entry(religionMaster).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; return(View()); } else { if (db.ReligionMaster.Any(x => (x.ReligionID != religionMaster.ReligionID) && (x.ReligionShortName == religionMaster.ReligionShortName))) { ViewBag.error = "Religion Short Name is Already exist!"; return(View()); } else { ViewBag.error = "Religion Name is Already exist!"; return(View()); } } } return(View(religionMaster)); }
public ActionResult Edit([Bind(Include = "Mode_ID,Mode_Type,Mode_Name,Mode_Short_Name")] HRMS_TravelMode_MS hRMS_TravelMode_MS) { if (ModelState.IsValid) { bool isValid = db.HRMS_TravelMode_MS.Any(x => (x.Mode_ID != hRMS_TravelMode_MS.Mode_ID) && ((x.Mode_Name == hRMS_TravelMode_MS.Mode_Name || x.Mode_Short_Name == hRMS_TravelMode_MS.Mode_Short_Name))); if (!isValid) { db.Entry(hRMS_TravelMode_MS).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; return(View()); } else { if (db.HRMS_TravelMode_MS.Any(x => (x.Mode_ID != hRMS_TravelMode_MS.Mode_ID) && ((x.Mode_Name == hRMS_TravelMode_MS.Mode_Name)))) { ViewBag.error = "Model Name is Already exist!"; return(View()); } else { ViewBag.error = "Model Short Name is Already exist!"; return(View()); } } } return(View(hRMS_TravelMode_MS)); }
public ActionResult Save(AT_Pages peg) { string msg = ""; try { Session_CRM sess = (Session_CRM)Session["CRM_Session"]; if (peg.PageID > 0) { db.AT_Pages.Attach(peg); db.UpdateExcept <AT_Pages>(peg); } else { db.Entry(peg).State = System.Data.Entity.EntityState.Added; } db.SaveChanges(); msg = "Page saved successfully!"; } catch (Exception ex) { msg = ex.Message; } ViewBag.msg = msg; db = new HRMSEntities(); return(PartialView("_Index", db.AT_Pages.ToList())); }
public IHttpActionResult PutEmployee(string id, Employee employee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employee.ID) { return(BadRequest()); } db.Entry(employee).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutProjects(int id, tblProject project) { if (id != project.ID) { return(BadRequest()); } db.Entry(project).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProjectExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "ID,Cost_Cntr_Code,Cost_Cntr_Name,Parent_Cost_Cntr_Code,Ledger_Code")] HRMS_COST_CENTER hRMS_COST_CENTER) { if (ModelState.IsValid) { var existData = db.HRMS_COST_CENTER.FirstOrDefault(rec => rec.Cost_Cntr_Code == hRMS_COST_CENTER.Cost_Cntr_Code && rec.Cost_Cntr_Name == hRMS_COST_CENTER.Cost_Cntr_Name); if (existData == null) { var existCode = db.HRMS_COST_CENTER.FirstOrDefault(rec => rec.Cost_Cntr_Code == hRMS_COST_CENTER.Cost_Cntr_Code); if (existCode == null) { var ExistName = db.HRMS_COST_CENTER.FirstOrDefault(rec => rec.Cost_Cntr_Name == hRMS_COST_CENTER.Cost_Cntr_Name); if (ExistName == null) { db.Entry(hRMS_COST_CENTER).State = EntityState.Modified; db.SaveChanges(); ViewBag.cost_Status = "Cost Updated succcessfully."; return(View()); } ViewBag.cost_Status = "This Cost Name is Already Exist ! "; return(View()); } ViewBag.cost_Status = "This Cost code is already exist !"; return(View()); } ViewBag.cost_Status = "this cost Code and Name is already exist !"; return(View()); } return(View(hRMS_COST_CENTER)); }
public IHttpActionResult PutTaskHistory(int task_id, tblTaskHistory taskHistory) { if (task_id != taskHistory.TASK_ID) { return(BadRequest()); } db.Entry(taskHistory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TaskHistoryExists(task_id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(Accounts accounts) { ModelState.Remove("password"); //because password is required if (ModelState.IsValid) { if (accounts.UserName != accounts.ConfirmUsername) { ViewBag.AccountStatus = "UserName Mismatched!"; return(View()); } bool isExist = db.Accounts.Any(x => x.ID != accounts.ID && x.UserName == accounts.UserName); if (isExist) { ViewBag.AccountStatus = "UserName Already Exist!"; return(View()); } db.Entry(accounts).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(accounts)); }
public IHttpActionResult PutUserMasters(int id, tblUserMaster UserMaster) { if (id != UserMaster.UserID) { return(BadRequest()); } db.Entry(UserMaster).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!UserMastersExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutHoliday(int id, tblHoliday holiday) { if (id != holiday.ID) { return(BadRequest()); } db.Entry(holiday).State = EntityState.Modified; holiday.HOLIDAY_DAY = holiday.HOLIDAY_DATE.DayOfWeek.ToString(); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!HolidayExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit([Bind(Include = "CitizenShip_ID,CitizenShip_Country_NM")] HRMS_EMP_CITIZENSHIP_MS hRMS_EMP_CITIZENSHIP_MS) { if (ModelState.IsValid) { bool isValid = db.HRMS_EMP_CITIZENSHIP_MS.Any(x => (x.CitizenShip_ID != hRMS_EMP_CITIZENSHIP_MS.CitizenShip_ID) && (x.CitizenShip_Country_NM == hRMS_EMP_CITIZENSHIP_MS.CitizenShip_Country_NM)); if (!isValid) { db.Entry(hRMS_EMP_CITIZENSHIP_MS).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; return(View()); } else { ViewBag.success = "It is Already exist!"; return(View()); } //db.Entry(hRMS_EMP_CITIZENSHIP_MS).State = EntityState.Modified; //db.SaveChanges(); //return RedirectToAction("Index"); } return(View(hRMS_EMP_CITIZENSHIP_MS)); }
public ActionResult Edit([Bind(Include = "CastCode,ReligionID,CastName")] CastMaster CastMasters) { //if (ModelState.IsValid) //{ // db.Entry(CastMasters).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.ReligionID = new SelectList(db.ReligionMaster, "ReligionID", "ReligionShortName", CastMasters.ReligionID); //return View(CastMasters); if (ModelState.IsValid) { bool isValid = db.CastMasters.Any(x => (x.CastCode != CastMasters.CastCode) && (x.ReligionID == CastMasters.ReligionID && x.CastName == CastMasters.CastName)); if (!isValid) { db.Entry(CastMasters).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View()); } else { ViewBag.error = "Sorry! This record is Already exist!"; ViewBag.ReligionID = new SelectList(db.ReligionMasters, "ReligionID", "ReligionName", CastMasters.ReligionID); return(View()); } } return(View(CastMasters)); }
public ActionResult _AgentSave(AT_Users usr) { string msg = ""; Session_CRM sess = (Session_CRM)Session["CRM_Session"]; try { // var UserType = db.AT_UserType.Where(x => x.UserType == "Agent").Select(x => x.TypeID).FirstOrDefault(); //usr.TypeID = UserType; // usr.ClientID = sess.User.ClientID; // AT_Agent det = usr.Agent; usr.Password = CRM_Common.Encrypt(usr.Password); if (usr.UserID > 0) { usr.UpdateBy = sess.User.UserID; usr.UpdateDate = DateTime.Now; db.AT_Users.Attach(usr); db.UpdateExcept <AT_Users>(usr, x => x.CreateBy, x => x.CreateDate); db.SaveChanges(); } else { usr.CreateBy = sess.User.UserID; usr.CreateDate = DateTime.Now; db.Entry(usr).State = System.Data.Entity.EntityState.Added; db.SaveChanges(); } msg = "User saved successfully!"; } catch (Exception ex) { if (ex.InnerException != null && ex.InnerException.ToString().Contains("UNIQUE")) { msg = "Conflict"; } else { msg = ex.Message; } } ViewBag.msg = msg; db = new HRMSEntities(); ViewBag.msg = msg; return(PartialView("_AgentIndex", db.AT_Users.Where(a => a.IsDeleted != true).ToList())); }
public ActionResult EditBank(BankMaster bankmaster) { bool isValid = db.BankMaster.Any(x => (x.BankCode != bankmaster.BankCode) && (x.BankName == bankmaster.BankName)); if (!isValid) { db.Entry(bankmaster).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; return(View()); } else { ViewBag.error = "Bank Name is Already exist!"; return(View()); } }
public ActionResult Edit([Bind(Include = "ID,EMP_ID,Is_Ref_Emp,Name,Country,State,City,Relationship,Pincode,Address,Designation,Company,PhoneNo,MobileNo,Email")] HRMS_EMP_ReferenceDetail hRMS_EMP_ReferenceDetail) { long emp_id = Convert.ToInt64(Session["id"]); string role = db.Accounts.Where(x => x.ID == emp_id).Select(x => x.role).FirstOrDefault(); if (role == "emp") { ModelState.Remove("EMP_ID"); hRMS_EMP_ReferenceDetail.EMP_ID = emp_id; } if (ModelState.IsValid) { bool isValid = db.HRMS_EMP_ReferenceDetail.Any(x => (x.ID != hRMS_EMP_ReferenceDetail.ID) && (x.EMP_ID == hRMS_EMP_ReferenceDetail.EMP_ID)); if (!isValid) { db.Entry(hRMS_EMP_ReferenceDetail).State = EntityState.Modified; db.SaveChanges(); ViewBag.success = "Your Record Successfully Updated!"; if (role == "emp") { long id = db.HRMS_EMP_ReferenceDetail.Where(x => x.EMP_ID == emp_id).Select(x => x.ID).FirstOrDefault(); return(RedirectToAction("Details", "EmployeeReferenceDetail", new { id })); } ViewBag.Country = new SelectList(db.Country, "CountryID", "CountryName"); ViewBag.State = new SelectList(db.State.Where(x => x.CountryID == hRMS_EMP_ReferenceDetail.Country), "StateID", "StateName"); ViewBag.City = new SelectList(db.City.Where(x => x.StateID == hRMS_EMP_ReferenceDetail.State), "CityID", "CityName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(hRMS_EMP_ReferenceDetail)); } else { ViewBag.error = "Sorry!"; ViewBag.Country = new SelectList(db.Country, "CountryID", "CountryName"); ViewBag.State = new SelectList(db.State.Where(x => x.CountryID == hRMS_EMP_ReferenceDetail.Country), "StateID", "StateName"); ViewBag.City = new SelectList(db.City.Where(x => x.StateID == hRMS_EMP_ReferenceDetail.State), "CityID", "CityName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(hRMS_EMP_ReferenceDetail)); } } ViewBag.Country = new SelectList(db.Country, "CountryID", "CountryName"); ViewBag.State = new SelectList(db.State.Where(x => x.CountryID == hRMS_EMP_ReferenceDetail.Country), "StateID", "StateName"); ViewBag.City = new SelectList(db.City.Where(x => x.StateID == hRMS_EMP_ReferenceDetail.State), "CityID", "CityName"); if (role == "admin") { ViewBag.Role = "admin"; } return(View(hRMS_EMP_ReferenceDetail)); }
public ActionResult Revieww(IEnumerable <string> Answer, IEnumerable <long> Question, IEnumerable <string> flag, String Textt, string Check) { //Answer.Zip(Question, Tuple.Create) //a:answer //b:question //c:flag long ProID = Convert.ToInt64(TempData["ProgramID"]); if (Textt == "") { TempData["Error"] = "Please!Fill the Rating!"; return(RedirectToAction("Review", new { id = ProID })); } long empid = Convert.ToInt64(Session["id"]); // long ProID =Convert.ToInt64(TempData["ProgramID"]); var results = Answer.ZipThree(Question, flag, (a, b, c) => new { a, b, c }); foreach (var item in results) { HRMS_TrainingReview obj = new HRMS_TrainingReview(); obj.Emp_ID = empid; obj.ProgramID = ProID; obj.QuestionID = item.b; obj.Date = DateTime.Now; obj.OtherComments = Textt; if (Check != null) { obj.IsWorthy = true; } else { obj.IsWorthy = false; } if (item.c == "False") //dropdown { obj.NonDescriptive = Convert.ToInt32(item.a); } else { obj.Descriptive = item.a; } db.HRMS_TrainingReview.Add(obj); db.SaveChanges(); } //flag insert in trainingApproval HRMS_TrainingApproval TA = db.HRMS_TrainingApproval.Where(x => x.Program_ID == ProID && x.EMP_ID == empid).FirstOrDefault(); TA.IsReviewDone = 1; //Review Done db.Entry(TA).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Meal_Expense_ID,Meal_Expense_NM,Meal_Expense_Status")] HRMS_TRAVEL_MEAL_EXPENSE_MS hRMS_TRAVEL_MEAL_EXPENSE_MS) { if (ModelState.IsValid) { db.Entry(hRMS_TRAVEL_MEAL_EXPENSE_MS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hRMS_TRAVEL_MEAL_EXPENSE_MS)); }
public ActionResult Edit([Bind(Include = "Designation_ID,Designation_Parent,Designation_ShortName,Designation_Name")] HRMS_EMP_DESIGNATION_MS hRMS_EMP_DESIGNATION_MS) { if (ModelState.IsValid) { db.Entry(hRMS_EMP_DESIGNATION_MS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hRMS_EMP_DESIGNATION_MS)); }
public ActionResult Edit([Bind(Include = "CitizenShip_ID,CitizenShip_Country_NM")] HRMS_EMP_CITIZENSHIP_MS hRMS_EMP_CITIZENSHIP_MS) { if (ModelState.IsValid) { db.Entry(hRMS_EMP_CITIZENSHIP_MS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hRMS_EMP_CITIZENSHIP_MS)); }
public ActionResult Edit([Bind(Include = "Gender_ID,Gender_Value")] HRMS_EMP_GENDER_MS hRMS_EMP_GENDER_MS) { if (ModelState.IsValid) { db.Entry(hRMS_EMP_GENDER_MS).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(hRMS_EMP_GENDER_MS)); }
public string UpdateQuestiondata(long id, string Question) { var question = db.HRMS_Evalution_Question.Where(rec => rec.ID == id).FirstOrDefault(); var exist = db.HRMS_Evalution_Question.Where(rec => rec.Question == Question && rec.ID != id && rec.Header_ID == question.Header_ID).Any(); if (exist == false) { question.Question = Question; db.Entry(question).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return("Data Updated Successfully."); } else { return("this Question is already exist!"); } }
public JsonResult EditEmployeeSelectiondata(HRMS_TrainingApproval hRMS_TrainingApproval) { //HRMS_TrainingApproval hRMS_TrainingApproval = employeeSelection.employeeSelection; var EmpDetails = db.HRMS_Emp_Details.Where(rec => rec.EMP_ID == hRMS_TrainingApproval.EMP_ID).FirstOrDefault(); hRMS_TrainingApproval.Designation = EmpDetails.Designation; hRMS_TrainingApproval.EmpDept = EmpDetails.Department; hRMS_TrainingApproval.EmpName = EmpDetails.Display_Name; hRMS_TrainingApproval.Status = 2; hRMS_TrainingApproval.ApproveBy = Convert.ToInt64(Session["id"]); hRMS_TrainingApproval.ApproveDate = DateTime.Now.Date; var exist = db.HRMS_TrainingApproval.Where(rec => rec.EMP_ID == hRMS_TrainingApproval.EMP_ID && rec.Program_ID == hRMS_TrainingApproval.Program_ID && rec.Status == 2).FirstOrDefault(); if (exist == null) { var existsameEmp = db.HRMS_TrainingApproval.Where(rec => rec.EMP_ID == hRMS_TrainingApproval.EMP_ID && rec.Program_ID == hRMS_TrainingApproval.Program_ID).FirstOrDefault(); if (existsameEmp == null) { db.HRMS_TrainingApproval.Add(hRMS_TrainingApproval); db.SaveChanges(); ModelState.Clear(); var status = "Employee Added successfullly."; return(Json(status, JsonRequestBehavior.AllowGet)); } else { existsameEmp.Status = 2; existsameEmp.FromTime = hRMS_TrainingApproval.FromTime; existsameEmp.ToTime = hRMS_TrainingApproval.ToTime; db.Entry(existsameEmp).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); var status = "Employee Added successfullly."; return(Json(status, JsonRequestBehavior.AllowGet)); } } else { var status = "Employee is already exist for this program!"; return(Json(status, JsonRequestBehavior.AllowGet)); } }
public ActionResult Edit([Bind(Include = "Travel_Other_Details_ID,Travel_Other_Details_NM")] HRMS_TRAVEL_OTHER_DETAILS_MS hRMS_TRAVEL_OTHER_DETAILS_MS) { if (ModelState.IsValid) { db.Entry(hRMS_TRAVEL_OTHER_DETAILS_MS).State = EntityState.Modified; db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); } return(View(hRMS_TRAVEL_OTHER_DETAILS_MS)); }