public async Task <IActionResult> Create([Bind("CommonAreaAssetId,AssetName,PurchasePrice,Description,Status,Date")] CommonAreaAsset commonAreaAsset) { if (ModelState.IsValid) { var identityUser = await _userManager.GetUserAsync(HttpContext.User); var loggedInUser = _context.Owner.Find(identityUser.OwnerId); commonAreaAsset.IsArchive = false; commonAreaAsset.LastModifiedBy = loggedInUser.FullName; commonAreaAsset.LastModifiedDate = DateTime.Now; _context.Add(commonAreaAsset); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(commonAreaAsset)); }
public async Task <IActionResult> Edit(int id, [Bind("CommonAreaAssetId,AssetName,PurchasePrice,Description,Status,Date,IsArchive,LastModifiedBy,LastModifiedDate")] CommonAreaAsset commonAreaAsset) { if (id != commonAreaAsset.CommonAreaAssetId) { return(NotFound()); } if (ModelState.IsValid) { try { var identityUser = await _userManager.GetUserAsync(HttpContext.User); var loggedInUser = _context.Owner.Find(identityUser.OwnerId); commonAreaAsset.LastModifiedBy = loggedInUser.FullName; commonAreaAsset.LastModifiedDate = DateTime.Now; _context.Update(commonAreaAsset); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommonAreaAssetExists(commonAreaAsset.CommonAreaAssetId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(commonAreaAsset)); }