public ActionResult Create(Project project) { try { MVCTestEntities db = new MVCTestEntities(); project.CreatedByName = User.Identity.Name; project.CreatedOn = DateTime.UtcNow; db.Projects.AddObject(project); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(Project comingproject) { try { MVCTestEntities db = new MVCTestEntities(); var project = db.Projects.Where(t => t.ProjectId == comingproject.ProjectId).SingleOrDefault(); if (project != null) { project.Name = comingproject.Name; project.Description = comingproject.Description; db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Create a new Project object. /// </summary> /// <param name="projectId">Initial value of the ProjectId property.</param> /// <param name="startDate">Initial value of the StartDate property.</param> /// <param name="createdOn">Initial value of the CreatedOn property.</param> /// <param name="createdByName">Initial value of the CreatedByName property.</param> public static Project CreateProject(global::System.Int32 projectId, global::System.DateTime startDate, global::System.DateTime createdOn, global::System.String createdByName) { Project project = new Project(); project.ProjectId = projectId; project.StartDate = startDate; project.CreatedOn = createdOn; project.CreatedByName = createdByName; return project; }
/// <summary> /// Deprecated Method for adding a new object to the Projects EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToProjects(Project project) { base.AddObject("Projects", project); }