public async Task <IActionResult> PutNation(int id, Nation nation) { if (id != nation.NationId) { return(BadRequest()); } _context.Entry(nation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutAsset(int id, Asset asset) { if (id != asset.AssetId) { return(BadRequest()); } _context.Entry(asset).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AssetExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutBranch(int id, Branch branch) { if (id != branch.BranchId) { return(BadRequest()); } _context.Entry(branch).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BranchExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEventParticipant(int id, EventParticipant eventParticipant) { if (id != eventParticipant.EventParticipantId) { return(BadRequest()); } _context.Entry(eventParticipant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventParticipantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Register(RegisterModel model) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } var user = await db.Пользователиs.FirstOrDefaultAsync(u => u.Логин == model.Login); if (user == null) { Guid salt = Guid.NewGuid(); string passwordWithSalt = model.Password + salt; string hashCode = ReturnHashCode(passwordWithSalt); Пользователи newUser = new Пользователи { Логин = model.Login, Пароль = hashCode, Соль = salt, ДатаРегистрации = DateTime.Now, IdРоли = db.ольs.FirstOrDefault(r => r.НаименованиеРоли == "Пользователь").IdРоли }; db.Пользователиs.Add(newUser); await db.SaveChangesAsync(); await Authenticate(newUser); return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Некорректные логин и/или пароль"); } return(View(model)); }