public async Task <IActionResult> Edit(string id, [Bind("Id,Name,NormalizedName,ConcurrencyStamp")] Roles roles) { if (id != roles.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(roles); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RolesExists(roles.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(roles)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,CompanyName,Address,SiteUrl,file,Icon")] CompanyInfo companyInfo, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (id != companyInfo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (companyInfo.file != null && companyInfo.file.Length > 0) { using (var memoryStream = new MemoryStream()) { await companyInfo.file.CopyToAsync(memoryStream); companyInfo.Icon = memoryStream.ToArray(); } } _context.Update(companyInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanyInfoExists(companyInfo.ID)) { return(NotFound()); } else { throw; } } if (returnUrl == null) { Redirect("Index"); } else { return(Redirect(returnUrl)); } } return(View(companyInfo)); }
public async Task <IActionResult> Edit(string id, [Bind("Address,NationalCode,FristName,LastName,Image,Imagefile,CompanyInfoID,SentEmail,SentSMS,Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] Users users, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; if (id != users.Id) { return(NotFound()); } if (ModelState.IsValid) { try { if (users.Imagefile != null && users.Imagefile.Length > 0) { using (var memoryStream = new MemoryStream()) { await users.Imagefile.CopyToAsync(memoryStream); users.Image = memoryStream.ToArray(); } } _context.Update(users); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsersExists(users.Id)) { return(NotFound()); } else { throw; } } return(RedirectToLocal(returnUrl)); } ViewData["CompanyInfoID"] = new SelectList(_context.tbCompanyInfos, "ID", "CompanyName", users.CompanyInfoID); return(View(users)); }