public async Task <IActionResult> OnPostAsync() { ViewData["Cities"] = new SelectList(_context.Cities.OrderBy(a => a.Name), "Id", "Name"); if (!ModelState.IsValid) { return(Page()); } _context.Attach(Shop).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShopExists(Shop.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./IndexShop")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Service = await _context.Service.FindAsync(id); if (Service != null) { var Agents = _context.Agent.Where(a => a.ShopId == Service.ShopId).ToList(); foreach (var item in Agents) { if (item.SevicesList.Contains(Service.Id + ":")) { item.SevicesList = item.SevicesList.Replace(Service.Id + ":", ""); _context.Attach(item).State = EntityState.Modified; } } _context.Service.Remove(Service); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(City).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CityExists(City.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } int v = await _context.Shop.Where(s => s.E_mail == _userManager.GetUserName(User)).Select(s => s.Id).FirstOrDefaultAsync(); Service.ShopId = v; _context.Attach(Service).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ServiceExists(Service.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int?id, string type) { if (!ModelState.IsValid) { return(Page()); } if (id == null || string.IsNullOrEmpty(type)) { return(NotFound()); } if (!VerifyFile()) { ModelState.AddModelError("File", "fichier Invalid"); return(Page()); } using (var memoryStream = new MemoryStream()) { await ImageUpload.FormFile.CopyToAsync(memoryStream); // Upload the file if less than 512 KB if (memoryStream.Length < 524288) { if (type == "shop") { var shop = await _context.Shop.FindAsync(id); shop.Image = memoryStream.ToArray(); _context.Attach(shop).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { } } else { ModelState.AddModelError("File", "The file is too large. must be less than 512 kb"); return(Page()); } } return(Redirect("/Panel/Manager/Details")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } if (!ModelState.IsValid) { return(Page()); } var agent = await _context.Agent.FindAsync(id); if (agent == null) { return(NotFound()); } agent.Name = Agent.Name; agent.HolidayEndDate = Agent.HolidayEndDate; _context.Attach(agent).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AgentExists(Agent.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }