public IActionResult Edit(Loan loan) { var signedInUserId = HttpContext.Session.GetInt32("LoggedInUser"); loan.LastModifiedBy = signedInUserId; loan.DateLastModified = DateTime.Now; var transaction = _databaseConnection.Transactions.Find(loan.TransactionId); var accountType = _databaseConnection.TransactionTypes.Find(loan.TransactionTypeId); if (accountType.Debit || accountType.Loan) { transaction.Action = TransactionAction.Debit.ToString(); } if (accountType.Credit) { transaction.Action = TransactionAction.Credit.ToString(); } _databaseConnection.Entry(transaction).State = EntityState.Modified; _databaseConnection.SaveChanges(); _databaseConnection.Entry(loan).State = EntityState.Modified; _databaseConnection.SaveChanges(); TempData["display"] = "You have successfully modified the loan!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); }
public IActionResult Edit(AppUser appUser, IFormFile Logo) { var signedInUserId = HttpContext.Session.GetInt32("LoggedInUser"); appUser.LastModifiedBy = signedInUserId; appUser.DateLastModified = DateTime.Now; //upload user logo if any file is uploaded if (Logo != null && !String.IsNullOrEmpty(Logo.FileName)) { var fileInfo = new FileInfo(Logo.FileName); var ext = fileInfo.Extension.ToLower(); var name = DateTime.Now.ToFileTime().ToString(); var fileName = name + ext; var uploadedImage = _hostingEnv.WebRootPath + $@"\UploadedFiles\ProfilePicture\{fileName}"; using (var fs = System.IO.File.Create(uploadedImage)) { if (fs != null) { Logo.CopyTo(fs); fs.Flush(); appUser.ProfilePicture = fileName; } } } _databaseConnection.Entry(appUser).State = EntityState.Modified; _databaseConnection.SaveChanges(); TempData["display"] = "You have successfully modified the member!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); }
public IActionResult Edit(Welfare welfare) { var signedInUserId = HttpContext.Session.GetInt32("LoggedInUser"); welfare.LastModifiedBy = signedInUserId; welfare.DateLastModified = DateTime.Now; _databaseConnection.Entry(welfare).State = EntityState.Modified; _databaseConnection.SaveChanges(); TempData["display"] = "You have successfully modified the Welfare Request!"; TempData["notificationtype"] = NotificationType.Success.ToString(); return(RedirectToAction("Index")); }