public ActionResult Edit(Project project) { if (ModelState.IsValid) { try { if (Session["PublicImageUrl"] != null) { project.ImgUrl = Session["PublicImageUrl"].ToString(); } ProjectsLogic.UpdateProject(project); return(RedirectToAction("Index")); Session["PublicImageUrl"] = ""; //return PartialView("JavascriptRedirect", new JavascriptRedirectModel("/Home/Index")); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "MoreHolidays/Projects/Edit(Post)", // Parameters = new JavaScriptSerializer().Serialize(project) }); Session["PublicImageUrl"] = ""; return(View(project)); } } return(View(project)); }
public ActionResult UpdateProject(ViewModel projectToUpdate) { if (Session["RoleId"] != null) { if (ModelState.IsValid) { Projects project = new Projects(); project = _projectMapper.MapProject(_projectBusinessLogic.GetProjectByProjectId(projectToUpdate.SingleProject.Project_ID)); if ((int)Session["UserId"] == projectToUpdate.SingleProject.User_ID || (int)Session["RoleID"] == 3) { _projectBusinessLogic.UpdateProject(projectToUpdate.SingleProject.Project_ID, _projectMapper.MapProject(projectToUpdate.SingleProject)); TempData["ProjectSuccess"] = "Project successfully updated."; return(RedirectToAction("ViewProjects", "Projects", new { area = "" })); } else { return(RedirectToAction("PageError", "Error", new { area = "" })); } } else { ViewModel projectViewModel = new ViewModel(); projectViewModel.Crafts = _craftMapper.MapCrafts(_craftBusinessLogic.GetCrafts()); projectViewModel.SingleProject.Project_ID = projectToUpdate.SingleProject.Project_ID; projectViewModel.SingleProject.User_ID = projectToUpdate.SingleProject.User_ID; projectViewModel.Difficulties = _difficultyMapper.MapDifficulties(_difficultyBusinessLogic.GetDifficulty()); return(View(projectViewModel)); } } else { return(RedirectToAction("Login", "Users", new { area = "" })); } } //update project for all users
public ActionResult Edit(Project project) { if (ModelState.IsValid) { try { project.UpdateDate = DateTimeHelper.Today(); ProjectsLogic.UpdateProject(project); return(RedirectToAction("Index", "Home")); } catch (Exception e) { LogsLogic.InsertLog(new Log() { Message = e.Message, StackTrace = e.StackTrace, StoryName = "ManagementProject/Projects/Edit(Post)", Parameters = new JavaScriptSerializer().Serialize(project) }); return(View(project)); } } return(View(project)); }