public async Task <IActionResult> OnPostAsync() { string[] data; data = otter.PlaceName.Split(';'); otter.LocationId = int.Parse(data[0]); otter.PlaceName = data[1]; _context.Attach(otter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VydraExists(otter.TattooID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("../Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { Otter = _context.Otters.Find(id); if (GetUserId() == Otter.FounderId || Otter.FounderId == null) { if (Otter != null) { foreach (var item in _context.Otters) { if (item.MotherId == Otter.TattooID) { item.MotherId = null; } } _context.Otters.Remove(Otter); await _context.SaveChangesAsync(); } return(RedirectToPage("../Index")); } else { Denied = "Pouze nálezce může vydru smazat."; return(Page()); } }
public async Task <IActionResult> OnPostAsync() { _context.Locations.Add(location); await _context.SaveChangesAsync(); return(RedirectToPage("../LocationIndex")); }
public async Task <IActionResult> OnPostAsync() { _context.Places.Add(place); await _context.SaveChangesAsync(); return(RedirectToPage("../PlacesIndex")); }
public async Task <IActionResult> OnPostAsync() { _context.Attach(location).State = EntityState.Modified; await _context.SaveChangesAsync(); return(RedirectToPage("../LocationIndex")); }
public async Task <Otter> CreateOtterAsync(Otter otter, string UserID) { string[] data; data = otter.PlaceName.Split(';'); Otter = new Otter() { Name = otter.Name, Color = otter.Color, MotherId = otter.MotherId, PlaceName = data[0], LocationId = int.Parse(data[1]), founderID = UserID }; _context.Otters.Add(Otter); await _context.SaveChangesAsync(); return(Otter); }
public async Task <IActionResult> OnPostAsync() { Otter.FounderId = GetUserId(); string[] data; data = Otter.PlaceName.Split(';'); Otter.LocationId = int.Parse(data[0]); Otter.PlaceName = data[1]; _context.Otters.Add(Otter); await _context.SaveChangesAsync(); return(RedirectToPage("../Index")); }
public async Task <IActionResult> OnPostAsync() { foreach (var item in _context.Otters) { if (item.LocationId == location.LocationID) { Denied = "V této lokaci žije nějaká vydra."; return(Page()); } } _context.Locations.Remove(location); await _context.SaveChangesAsync(); return(RedirectToPage("../LocationIndex")); }
public async Task <IActionResult> OnPostAsync() { Place NewPlace = place; foreach (var item in _context.Otters) { if (item.PlaceName == place.Name && item.LocationId == place.LocationId) { item.Place = Edit; } } _context.Places.Remove(place); await _context.SaveChangesAsync(); NewPlace.LocationId = Edit.LocationId; NewPlace.Name = Edit.Name; _context.Places.Add(NewPlace); await _context.SaveChangesAsync(); return(RedirectToPage("../PlacesIndex")); }
public async Task <IActionResult> OnPostAsync() { foreach (var item in _context.Otters) { if (item.PlaceName == place.Name && item.LocationId == place.LocationId) { Denied = "Na tomto místě žije nějaká vydra."; return(Page()); } } _context.Places.Remove(place); await _context.SaveChangesAsync(); return(RedirectToPage("../PlacesIndex")); }
public async Task <IActionResult> OnPostAsync(int?id) { Otter = _context.Otters.Find(id); if (GetUserId() == Otter.FounderId) { if (Otter != null) { _context.Otters.Remove(Otter); await _context.SaveChangesAsync(); } return(RedirectToPage("../Index")); } else { return(RedirectToPage("./Denied")); } }
public async Task <IActionResult> OnPostAsync() { /*if (!ModelState.IsValid) * { * return Page(); * }*/ if (Set.Role == null) { return(RedirectToPage("./Index")); } if (_context.UserRoles.Find(new string[] { Set.User, Set.Role }) == null) { _context.UserRoles.Add(new IdentityUserRole <string> { UserId = Set.User, RoleId = Set.Role }); } await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }