public async Task <IActionResult> Edit(int id, AppMonModel applicationModel) { if (id != applicationModel.ID) { return(NotFound()); } if (ModelState.IsValid) { DateTime dateTimeNow = DateTime.Now; UserModel userModel = GetUserModel(); NsapplicationsT nsapplicationsTOld = await _context.NsapplicationsT.SingleAsync(entity => entity.Id == applicationModel.ID); if (nsapplicationsTOld == null) { return(NotFound()); } nsapplicationsTOld.IsActive = false; nsapplicationsTOld.UpdatedDate = dateTimeNow; NsapplicationsT nsapplicationsTNew = new NsapplicationsT { CreatedDate = dateTimeNow, Interval = applicationModel.Interval, IsActive = true, Name = applicationModel.Name, Url = applicationModel.URL, UserId = userModel.ID }; try { _context.Update(nsapplicationsTOld); _context.Add(nsapplicationsTNew); await _context.SaveChangesAsync(); await UpdateTempData(userModel.ID); } catch (DbUpdateConcurrencyException) { if (!NsapplicationsTExists(nsapplicationsTOld.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(applicationModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Language,ResourceKey,ResourceText")] NsresourcesT nsresourcesT) { if (id != nsresourcesT.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nsresourcesT); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NsresourcesTExists(nsresourcesT.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(nsresourcesT)); }