public ActionResult Create(ProjectEdit project) { if (SaveObject(project, false)) return RedirectToAction("Index", new { id = project.Id }); else return View(); }
public ActionResult Edit(int id, ProjectEdit project) { LoadProperty(project, ProjectEdit.IdProperty, id); if (SaveObject(project, true)) return RedirectToAction("Index"); else return View(); }
//Func Desc: Used to return a project from its id. // Input: Int representing id of project to locate. // Output: An instance of the project that has the specified id, or null public bool EditProject(object vm_project) { //Input checks if (vm_project == null) { return false; } if ( (vm_project.GetType() != typeof(AdminProjectViewModel)) && (vm_project.GetType() != typeof(AmbassProjectViewModel)) && (vm_project.GetType() != typeof(ContributorProjectViewModel))) { //Invalid view model Debug.WriteLine("\n\n***** " + "View model input into EditProject of ContributorAccess is invalid in type. " + "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess EditProject()" + "*****\n\n" ); //Indicate failure in status return false; } using (var context = new MainDBEntities()) { ApplicationSpecificMapper mapper = new ApplicationSpecificMapper(); if (this.GetType() == typeof(AdminAccess)) { Project proj = (Project)mapper.Map((AdminProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return true; } else if (this.GetType() == typeof(AmbassadorAccess)) { Project proj = (Project)mapper.Map((AmbassProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return true; } else if (this.GetType() == typeof(ContributorAccess)) { Project proj = (Project)mapper.Map((ContributorProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return true; } else { //Access type not recognized Debug.WriteLine("\n\n***** " + "Access object type wasn't recognized during EditProject(). " + "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess EditProject()" + "*****\n\n"); //Indicate error status return false; } } }
public ProjectResourceDisplay(ProjectEdit parent, ProjectTracker.Library.ProjectResourceEdit projectResource) { Parent = parent; ManageObjectLifetime = false; Model = projectResource; }
public ActionResult Edit(int id) { ViewData.Model = ProjectEdit.GetProject(id); return(View()); }
public ActionResult Create() { ViewData.Model = ProjectEdit.NewProject(); return(View()); }
//Func Desc: Used to return a project from its id. // Input: Int representing id of project to locate. // Output: An instance of the project that has the specified id, or null public bool EditProject(object vm_project) { //Input checks if (vm_project == null) { return(false); } if ((vm_project.GetType() != typeof(AdminProjectViewModel)) && (vm_project.GetType() != typeof(AmbassProjectViewModel)) && (vm_project.GetType() != typeof(ContributorProjectViewModel))) { //Invalid view model Debug.WriteLine("\n\n***** " + "View model input into EditProject of ContributorAccess is invalid in type. " + "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess EditProject()" + "*****\n\n"); //Indicate failure in status return(false); } using (var context = new MainDBEntities()) { ApplicationSpecificMapper mapper = new ApplicationSpecificMapper(); if (this.GetType() == typeof(AdminAccess)) { Project proj = (Project)mapper.Map((AdminProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return(true); } else if (this.GetType() == typeof(AmbassadorAccess)) { Project proj = (Project)mapper.Map((AmbassProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return(true); } else if (this.GetType() == typeof(ContributorAccess)) { Project proj = (Project)mapper.Map((ContributorProjectViewModel)vm_project, typeof(Project)); //Create the project edit and populate necessary attributes ProjectEdit edit = new ProjectEdit(); edit.Username = proj.Username; edit.ProjectID = proj.ProjectID; edit.EditDate = DateTime.Now; context.ProjectEdits.Add(edit); //Indicate modification and make changes persistent context.Entry(proj).State = EntityState.Modified; context.SaveChanges(); //Return true indicating successful project edit return(true); } else { //Access type not recognized Debug.WriteLine("\n\n***** " + "Access object type wasn't recognized during EditProject(). " + "ERROR IN: CommerceIdeaBank.DatabaseInterface.BusinessLogic.ContributorAccess EditProject()" + "*****\n\n"); //Indicate error status return(false); } } }