public async Task <IActionResult> PutOrders(int id, DataModels.Orders orders) { if (id != orders.OrderId) { return(BadRequest()); } try { var mapaux = _mapper.Map <datamodels.Orders, data.Orders>(orders); new BS.Orders(_context).Update(mapaux); } catch (Exception ee) { if (!OrdersExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <DataModels.Orders> > PostOrders(DataModels.Orders orders) { var mapaux = _mapper.Map <datamodels.Orders, data.Orders>(orders); new BS.Orders(_context).Insert(mapaux); return(CreatedAtAction("GetOrders", new { id = orders.OrderId }, orders)); }
public async Task AddOrdersAsync(SleepingSelkieBusinessLogic.BusinessModels.Orders order) { var newOrder = new DataModels.Orders { Customer = dbContext.Customers .Where(x => x.CustomerID == order.CustomerID).FirstOrDefault(), Store = dbContext.Stores .Where(x => x.StoreName == order.StoreName).FirstOrDefault(), ManaPotionsBought = order.ManaPotionsBought, StaminaPotionsBought = order.StaminaPotionsBought, HealthPotionsBought = order.HealthPotionsBought, ClericsTalismanBought = order.ClericsTalismanBought, MagicWandsBought = order.MagicWandsBought, Date = order.Date, }; dbContext.Add(newOrder); await dbContext.SaveChangesAsync(); }