public async Task <IActionResult> Edit(int id, [Bind("PostPressID,Name,Description,IsActive,AddedDate,UpdatedDate,AddedUserID,UpdatedUserID")] PostPress postPress) { if (id != postPress.PostPressID) { return(NotFound()); } if (ModelState.IsValid) { try { postPress.UpdatedDate = DateTime.Now; postPress.UpdatedUserID = Int32.Parse(HttpContext.Session.GetString("UserID")); _context.Update(postPress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostPressExists(postPress.PostPressID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AddedUserID"] = new SelectList(_context.Users, "UserID", "Login", postPress.AddedUserID); ViewData["UpdatedUserID"] = new SelectList(_context.Users, "UserID", "Login", postPress.UpdatedUserID); return(View(postPress)); }
public async Task <IActionResult> Create([Bind("PostPressID,Name,Description,IsActive,AddedDate,UpdatedDate,AddedUserID,UpdatedUserID")] PostPress postPress) { if (ModelState.IsValid) { postPress.IsActive = true; postPress.AddedDate = DateTime.Now; postPress.AddedUserID = Int32.Parse(HttpContext.Session.GetString("UserID")); _context.Add(postPress); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AddedUserID"] = new SelectList(_context.Users, "UserID", "Login", postPress.AddedUserID); ViewData["UpdatedUserID"] = new SelectList(_context.Users, "UserID", "Login", postPress.UpdatedUserID); return(View(postPress)); }