public async Task <IActionResult> PutCustomOrders([FromRoute] int id, [FromBody] CustomOrders customOrders) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != customOrders.Id) { return(BadRequest()); } _context.Entry(customOrders).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomOrdersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult CreateOrder(Product product) { using (DatabaseContext db = new DatabaseContext()) { CustomOrders produ = new CustomOrders(); produ.idproduct = product.idProducts; produ.idClient = (int)HttpContext.Session.GetInt32("Id"); produ.ProductName = product.ProductName; produ.Price = product.Price; produ.ProductDesc = product.ProductDesc; produ.Color = product.Color; produ.Dimensions = product.Dimensions; produ.Materials = product.Materials; db.CustomOrders.Add(produ); int filasAfectadas = db.SaveChanges(); if (filasAfectadas > 0) { TempData["pedido"] = 1; } return(RedirectToAction("IndexOrder")); } }
public async Task <IActionResult> PostCustomOrders([FromBody] CustomOrders customOrders) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.CustomOrders.Add(customOrders); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCustomOrders", new { id = customOrders.Id }, customOrders)); }
public async Task <IActionResult> Create(int StoreId, [Bind("CustomOrderID,Status,Username,AddressLine1,AddressLine2,email,PhoneNum,OrderCreatedDate,Description,ProductType,Chest,Neck,Shoulder,Sleeve,Waist,Hip,InseamLength,FullLength,AnkleLength")] CustomOrders customOrders) { if (ModelState.IsValid) { _context.Add(customOrders); customOrders.status = true; customOrders.StoreId = StoreId; customOrders.OrderCreatedDate = DateTime.Now; await _context.SaveChangesAsync(); return(RedirectToAction("ProductList", "Products", new { id = StoreId })); } return(RedirectToAction("ProductList", "Products", new { id = StoreId })); }