public async Task <IActionResult> Create([Bind("Id,StartTime,EndTime")] Order order) { if (ModelState.IsValid) { _context.Add(order); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(order)); }
public async Task <IActionResult> Create([Bind("Id,Dosage,Price,Name,Type,Description")] Drug drug) { if (ModelState.IsValid) { _context.Add(drug); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(drug)); }
public async Task <IActionResult> Create([Bind("Id,Name,Address,DoctorForeignKey")] Organization organization) { if (ModelState.IsValid) { _context.Add(organization); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DoctorForeignKey"] = new SelectList(_context.Doctor, "Id", "Id", organization.DoctorForeignKey); return(View(organization)); }
public async Task <IActionResult> Create([Bind("Id,Firstname,Lastname,DoctorId")] Patient patient) { if (ModelState.IsValid) { _context.Add(patient); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DoctorId"] = new SelectList(_context.Doctor, "Id", "Id", patient.DoctorId); return(View(patient)); }
public async Task <IActionResult> Create([Bind("ProdusID,NumeMedicament,CategorieID,FurnizorID,Doza,Pret,DataExpirare")] Produs produs) { if (ModelState.IsValid) { _context.Add(produs); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategorieID"] = new SelectList(_context.Categorii, "CategorieID", "CategorieID", produs.CategorieID); ViewData["FurnizorID"] = new SelectList(_context.Furnizori, "FurnizorID", "FurnizorID", produs.FurnizorID); return(View(produs)); }
public async Task <IActionResult> Create([Bind("Name,Cnpj,Address,PostCode,Phone,Email")] Supplier supplier) { if (ModelState.IsValid) { _context.Add(supplier); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(supplier)); }
public async Task <IActionResult> Create( [Bind("Id,Name,Description,Price,Batch,Type,SupplierId")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["SupplierId"] = new SelectList(_context.Suppliers, "Id", "Name", product.SupplierId); return(View(product)); }
public async Task <IActionResult> DeleteConfirmed(long id) { var sale = await _context.Sales.SingleOrDefaultAsync(m => m.Id == id); _context.Sales.Remove(sale); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("NumeCategorie")] Categorie categorie) { try { if (ModelState.IsValid) { _context.Add(categorie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(categorie)); }
public async Task <IActionResult> Create(CreateCategoryViewModel model) { if (ModelState.IsValid) { var category = new Category { Name = model.Name, Description = model.Description }; _context.Categories.Add(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public async Task <IActionResult> PutOrder(int id, Order order) { if (id != order.OrderId) { return(BadRequest()); } _context.Entry(order).State = EntityState.Modified; bool isItemsUpdated = false; foreach (var item in order.Items) { _context.Entry(item).State = EntityState.Modified; isItemsUpdated = true; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return(NotFound()); } else if (isItemsUpdated) { return(NoContent()); } else { throw; } } return(NoContent()); }
public async Task Add(T entity) { await _context.Set <T>().AddAsync(entity); await _context.SaveChangesAsync(); }
public Task Save() { return(context.SaveChangesAsync()); }