public ActionResult Edit([Bind(Include = "ProjectId,Title,Author,CategoryId,DepartmentId,Document,SessionId,CreatedBy")] Project project, FormCollection collectedValues) { var loggedinuser = Session["courseshuffleloggedinuser"] as AppUser; if (ModelState.IsValid) { if (loggedinuser != null) { project.StartDate = Convert.ToDateTime(collectedValues["StartDate"]); project.EndDate = Convert.ToDateTime(collectedValues["EndDate"]); project.DateCreated = Convert.ToDateTime(collectedValues["DateCreated"]); project.DateLastModified = DateTime.Now; project.LastModifiedBy = loggedinuser.AppUserId; _db.Entry(project).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } TempData["project"] = "Your session has expired,Login Again!"; TempData["notificationtype"] = NotificationType.Info.ToString(); return(RedirectToAction("Index")); } ViewBag.SessionId = new SelectList(_db.Sessions, "SessionId", "Name", project.SessionId); ViewBag.DepartmentId = new SelectList(_db.Departments, "DepartmentId", "Name", project.DepartmentId); return(View(project)); }
public Application Update(int id, Application application) { var applicationToUpdate = GetById(id); if (applicationToUpdate == null) { return(null); } applicationToUpdate = application; //applicationToUpdate.IIN = application.IIN; //applicationToUpdate.Score = application.Score; //applicationToUpdate.Profile1 = application.Profile1; //applicationToUpdate.Profile2 = application.Profile2; //applicationToUpdate.University = application.University; _context.Applications.Update(applicationToUpdate); _context.Entry(application).State = EntityState.Modified; _context.SaveChanges(); return(applicationToUpdate); }
/// <summary> обновление только сущности </summary> public virtual void Update(T entity) { dbSet.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }