public async Task <IActionResult> Edit(int id, [Bind("Id,UserId,BoroughId,Status,Created,CreatedBy,Updated,UpdatedBy")] UserBorough userBorough) { if (id != userBorough.Id) { return(NotFound()); } if (ModelState.IsValid) { try { userBorough.Updated = DateTime.Now; userBorough.UpdatedBy = User.Identity.Name; _context.Update(userBorough); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserBoroughExists(userBorough.Id)) { return(NotFound()); } else { throw; } } //return RedirectToAction(nameof(Index)); return(RedirectToAction("Details", "Users", new { id = userBorough.UserId })); } ViewData["BoroughId"] = new SelectList(_context.Boroughs, "Id", "Name", userBorough.BoroughId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "FullName", userBorough.UserId); ViewData["Status"] = new SelectList(Utils.Extensions.GetRecordStatusList(), "Value", "Text", userBorough.Status); return(View(userBorough)); }
public async Task <IActionResult> Create([Bind("Id,UserId,BoroughId,Status,Created,CreatedBy,Updated,UpdatedBy")] UserBorough userBorough) { if (ModelState.IsValid) { userBorough.Created = DateTime.Now; userBorough.Updated = DateTime.Now; userBorough.CreatedBy = User.Identity.Name; userBorough.UpdatedBy = User.Identity.Name; _context.Add(userBorough); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); return(RedirectToAction("Details", "Users", new { id = userBorough.UserId })); } ViewData["BoroughId"] = new SelectList(_context.Boroughs, "Id", "Name", userBorough.BoroughId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "FullName", userBorough.UserId); ViewData["Status"] = new SelectList(Utils.Extensions.GetRecordStatusList(), "Value", "Text", userBorough.Status); return(View(userBorough)); }