public async Task <IActionResult> Edit(int id, [Bind("Id,ListOfRentsId,StartDate,EndDate,Cost,CreateDate,ApplicationUserId")] ListOfRentsHistory listOfRentsHistory) { if (id != listOfRentsHistory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { string uid = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; listOfRentsHistory.ApplicationUserId = uid; _context.Update(listOfRentsHistory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ListOfRentsHistoryExists(listOfRentsHistory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ListOfRentsId"] = new SelectList(_context.ListOfRents, "Id", "NameRus", listOfRentsHistory.ListOfRentsId); return(View(listOfRentsHistory)); }
public async Task <IActionResult> Create([Bind("Id,ListOfRentsId,StartDate,EndDate,Cost,CreateDate,ApplicationUserId")] ListOfRentsHistory listOfRentsHistory) { if (ModelState.IsValid) { _context.Add(listOfRentsHistory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ListOfRentsId"] = new SelectList(_context.ListOfRents, "Id", "NameRus", listOfRentsHistory.ListOfRentsId); return(View(listOfRentsHistory)); }
// GET: Rents/ListOfRentsHistories/Create public IActionResult Create() { ViewData["ListOfRentsId"] = new SelectList(_context.ListOfRents, "Id", "NameRus"); string uid = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; ListOfRentsHistory model = new ListOfRentsHistory(); model.CreateDate = DateTime.Now; model.ApplicationUserId = uid; return(View(model)); }