public ActionResult Edit(EnumSubject model) { if (ModelState.IsValid) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Edit([Bind("Id", "IdSubject", "IdApplication", "Degree")] TutorApplicationSubject tutorApplicationSubject) { if (ModelState.IsValid) { db.Entry(tutorApplicationSubject).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubjectID = new SelectList(db.EnumSubject, "ID", "Code", tutorApplicationSubject.IdSubject); ViewBag.ApplicationID = new SelectList(db.TutorApplication, "ID", "ID", tutorApplicationSubject.IdApplication); return(View(tutorApplicationSubject)); }
public ActionResult Edit([Bind("ID,TimeFrom,TimeTo,SubjectID,TutorID,IsAccepted,IsCancelled,CancellationComment")] Event @event) { if (ModelState.IsValid) { db.Entry(@event).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SubjectID = new SelectList(db.EnumSubject, "ID", "Code", @event.IdSubject); ViewBag.TutorID = new SelectList(db.SscisUser, "ID", "Login", @event.IdTutor); return(View(@event)); }
public ActionResult Edit([Bind("Id", "ParamKey", "ParamValue", "Description")] SscisParam sSCISParam) { if (ModelState.IsValid) { if (sSCISParam.ParamKey.Contains("HTML")) { sSCISParam.ParamValue = WebUtility.HtmlEncode(sSCISParam.ParamValue); } if (sSCISParam.ParamKey.Contains("ADMIN_PASSWORD")) { sSCISParam.ParamValue = new PasswordHash().Encode(sSCISParam.ParamValue); } db.Entry(sSCISParam).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sSCISParam)); }
public ActionResult Edit(EditUser editUser) { if (ModelState.IsValid) { editUser.User.IdRoleNavigation = db.EnumRole.Find(editUser.User.IdRole); db.Entry(editUser.User).State = EntityState.Modified; if (editUser.User.IdRoleNavigation.Role.Equals("USER")) { List <Approval> userApproval = db.Approval.Where(a => a.IdTutor == editUser.User.Id).ToList(); foreach (Approval approval in userApproval) { db.Approval.Remove(approval); } List <Event> userEvent = db.Event.Where(a => a.IdTutor == editUser.User.Id).ToList(); foreach (Event sscisEvent in userEvent) { int authorID = (int)HttpContext.Session.GetInt32("userId"); SscisUser currentLoggedUser = db.SscisUser.Find((int)authorID); sscisEvent.IdTutorNavigation = currentLoggedUser; sscisEvent.CancelationComment = "Tutor fired!"; sscisEvent.IsCancelled = true; } } else if (editUser.User.IdRoleNavigation.Role.Equals("ADMIN")) { List <Approval> userApproval = db.Approval.Where(a => a.IdTutor == editUser.User.Id).ToList(); foreach (Approval approval in userApproval) { db.Approval.Remove(approval); } List <EnumSubject> subjects = db.EnumSubject.Where(s => s.IdParent == null && s.Lesson == false).ToList(); foreach (EnumSubject subject in subjects) { Approval newApproval = new Approval(); newApproval.IdSubject = subject.Id; newApproval.IdSubjectNavigation = db.EnumSubject.Find(subject.Id); newApproval.IdTutor = editUser.User.Id; newApproval.IdTutorNavigation = db.SscisUser.Find(editUser.User.Id); db.Approval.Add(newApproval); db.SaveChanges(); } } else { foreach (MetaApproval app in editUser.Approvals) { if (app.Approved == true) { List <Approval> tmp = db.Approval.Where(a => a.IdTutor == editUser.User.Id && a.IdSubject == app.EnumSubject.Id).ToList(); if (tmp.Count == 0) { Approval newApproval = new Approval(); newApproval.IdSubject = app.EnumSubject.Id; newApproval.IdSubjectNavigation = db.EnumSubject.Find(app.EnumSubject.Id); newApproval.IdTutor = editUser.User.Id; newApproval.IdTutorNavigation = db.SscisUser.Find(editUser.User.Id); db.Approval.Add(newApproval); db.SaveChanges(); } } else { List <Approval> tmp = db.Approval.Where(a => a.IdTutor == editUser.User.Id && a.IdSubject == app.EnumSubject.Id).ToList(); foreach (Approval app2 in tmp) { db.Approval.Remove(app2); } } } } editUser.Approvals = null; db.Entry(editUser.User).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleID = new SelectList(db.EnumRole, "Id", "Role", editUser.User.IdRole); ViewBag.ActivatedByID = new SelectList(db.SscisUser, "Id", "Login", editUser.User.IsActivatedBy); return(View(editUser.User)); }