public IActionResult Create(CreateChairmanCadidate candidate) { if (ModelState.IsValid) { if (userService.Email() == userService.AdminEmail()) { MemberMan member = new MemberMan(); var uploadFolder = Path.Combine(environment.WebRootPath, "images"); string uniqueFileName = Guid.NewGuid().ToString() + "_" + candidate.ProfilePicPath.FileName; string filePath = Path.Combine(uploadFolder, uniqueFileName); candidate.ProfilePicPath.CopyTo(new FileStream(filePath, FileMode.Create)); member.ProfilePicPath = uniqueFileName; uploadFolder = Path.Combine(environment.WebRootPath, "images"); uniqueFileName = Guid.NewGuid().ToString() + "_" + candidate.SymbolPath.FileName; filePath = Path.Combine(uploadFolder, uniqueFileName); candidate.SymbolPath.CopyTo(new FileStream(filePath, FileMode.Create)); member.SymbolPath = uniqueFileName; member.Name = candidate.Name; member.Email = candidate.Email; if (memberManager.Add(member)) { return(RedirectToAction(nameof(Index))); } } } return(View(candidate)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,ProfilePicPath,SymbolPath,TotalVote")] MemberMan memberMan) { if (id != memberMan.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(memberMan); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberManExists(memberMan.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(memberMan)); }