public async Task <IActionResult> Create([Bind("ID,CustomerID,LocationID")] Cart cart) { if (ModelState.IsValid) { _context.Add(cart); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cart)); }
public async Task <IActionResult> Create([Bind("ID,LocationID,ProductID,Quantity")] Inventory inventory) { if (ModelState.IsValid) { _context.Add(inventory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(inventory)); }
public async Task <IActionResult> Create([Bind("ID,OrderID,ProductID,Quantity")] LineItem lineItem) { if (ModelState.IsValid) { _context.Add(lineItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(lineItem)); }
public async Task <IActionResult> Create([Bind("ID,Athlete,Item,Sport,Price")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Post(string values) { var model = new Employee(); var valuesDict = JsonConvert.DeserializeObject <IDictionary>(values); PopulateModel(model, valuesDict); if (!TryValidateModel(model)) { return(BadRequest(GetFullErrorMessage(ModelState))); } var result = _context.Employeedb.Add(model); await _context.SaveChangesAsync(); return(Json(new { result.Entity.empid })); }
public async Task <IActionResult> DeleteConfirmed(int id) { var cartItem = await _context.CartItem.FindAsync(id); _context.CartItem.Remove(cartItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create([Bind("ID,CustomerID,LocationID,OrderDate,Price")] 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,Username,Email")] Customer customer) { if (ModelState.IsValid) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Post([FromBody] Employee emp) { //if(ModelState.IsValid==false) if (!ModelState.IsValid) { return(BadRequest(ModelState)); } context.Emp.Add(emp); int rows = await context.SaveChangesAsync(); if (rows > 0) { return(StatusCode(201)); } return(BadRequest("Failed to save employee")); }