public async Task <IActionResult> Edit(Guid id, [Bind("LicenseHolderName,IdentificationNumber,CraftOrIndustryType,ClassifiedInTail,Address,Ends,LicenseFee,VoucherNumber,ID,CreatedDate,UpdatedDate,UserID,Deleted")] CraftAndIndustryLicense craftAndIndustryLicense) { if (id != craftAndIndustryLicense.ID) { return(NotFound()); } if (ModelState.IsValid) { try { craftAndIndustryLicense.UpdatedDate = DateTime.UtcNow; _context.Update(craftAndIndustryLicense); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CraftAndIndustryLicenseExists(craftAndIndustryLicense.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserID"] = new SelectList(_context.Users, "Id", "Id", craftAndIndustryLicense.UserID); return(View(craftAndIndustryLicense)); }
public async Task <IActionResult> Create([Bind("LicenseHolderName,IdentificationNumber,CraftOrIndustryType,ClassifiedInTail,Address,Ends,LicenseFee,VoucherNumber,ID,CreatedDate,UpdatedDate,UserID,Deleted")] CraftAndIndustryLicense craftAndIndustryLicense) { if (ModelState.IsValid) { var datetime = DateTime.UtcNow; craftAndIndustryLicense.ID = Guid.NewGuid(); craftAndIndustryLicense.CreatedDate = datetime; craftAndIndustryLicense.UpdatedDate = datetime; craftAndIndustryLicense.UserID = usermanager.GetUserId(User); _context.Add(craftAndIndustryLicense); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(craftAndIndustryLicense)); }