public async Task <IActionResult> Create([Bind("ID,Name,Address")] Providers providers) { if (ModelState.IsValid) { _context.Add(providers); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(providers)); }
public async Task <IActionResult> Create([Bind("ID,Name,Price,BrandsID")] Products products) { if (ModelState.IsValid) { _context.Add(products); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BrandsID"] = new SelectList(_context.Brands, "ID", "Name", products.Brands.Name); return(View(products)); }
public async Task <IActionResult> Create([Bind("ID,Name,Address,OwnersID")] Shops shops) { if (ModelState.IsValid) { _context.Add(shops); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["OwnersID"] = new SelectList(_context.Owners, "ID", "Name", shops.Owners.Name); return(View(shops)); }
public async Task <IActionResult> Create([Bind("ID,Name,Info,ProvidersID")] Brands brands) { if (ModelState.IsValid) { _context.Add(brands); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProvidersID"] = new SelectList(_context.Providers, "ID", "Name", brands.Providers.Name); return(View(brands)); }
public void AddTS(TS ts) { if (!ModelState.IsValid) { var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage)); throw new Exception("Модель не валидна: " + message); } else { repo.Add(ts, out status); foreach (var d in ModelState.Select(x => x.Value.Errors).Where(y => y.Count > 0).ToList()) { ; } if (status != "ok") { throw new Exception(status); } } }