public async Task <AddItemApiModel.ResponseByOneItem> PostAsync(AddItemApiModel.Request request) { //try //{ return(await _ordersInterface.PostItemsDetailes(request)); //} //catch //{ // return null; //} }
public async Task <AddItemApiModel.Response> PostAsync(AddItemApiModel.Request request) { //do try catch return(await _ordersInterface.PostOrderDetailes(request)); }
public async Task <AddItemApiModel.ResponseByOneItem> PostItemsDetailes(AddItemApiModel.Request OrderDetailes) { if (OrderDetailes.isCourceMaterial == true) { Item newItem = new Item { itemId = new Guid(), orderId = new Guid(OrderDetailes.orderId), isPrintingOrder = OrderDetailes.isPrintingOrder, isCourceMaterial = OrderDetailes.isCourceMaterial, courceMaterialId = new Guid(OrderDetailes.courseId), docId = new Guid(OrderDetailes.docId), totalPriceOfTheItem = OrderDetailes.totalPriceOfTheItem, printingShopId = new Guid(OrderDetailes.printingShopId) }; await applicationDbContext.items.AddAsync(newItem); await applicationDbContext.SaveChangesAsync(); AddItemApiModel.ResponseByOneItem rsulte = new AddItemApiModel.ResponseByOneItem { itemId = newItem.itemId.ToString(), itemPrice = newItem.totalPriceOfTheItem, orderId = newItem.orderId.ToString(), printingShopID = newItem.printingShopId.ToString(), errorMassage = "", }; return(rsulte); } else { Item newItem = new Item { itemId = new Guid(), orderId = new Guid(OrderDetailes.orderId), isPrintingOrder = OrderDetailes.isPrintingOrder, isCourceMaterial = OrderDetailes.isCourceMaterial, courceMaterialId = new Guid("23C55B9B-8835-43A3-C7A5-08D8FCB452F0"), //defult null cource Material docId = new Guid("AAAAAAAA-0101-0101-0101-C00000000000"), //defult null document totalPriceOfTheItem = OrderDetailes.totalPriceOfTheItem, printingShopId = new Guid(OrderDetailes.printingShopId), ThePrintingDetailes = OrderDetailes.description }; await applicationDbContext.items.AddAsync(newItem); await applicationDbContext.SaveChangesAsync(); AddItemApiModel.ResponseByOneItem rsulte = new AddItemApiModel.ResponseByOneItem { itemId = newItem.itemId.ToString(), itemPrice = newItem.totalPriceOfTheItem, orderId = newItem.orderId.ToString(), printingShopID = newItem.printingShopId.ToString(), errorMassage = "", }; return(rsulte); } }
public async Task <AddItemApiModel.Response> PostOrderDetailes(AddItemApiModel.Request OrderDetailes) { if (OrderDetailes.orderId == null || OrderDetailes.orderId == "") { Order order = new Order { orderId = new Guid(), total = OrderDetailes.totalPriceOfTheItem, CustomerId = new Guid(OrderDetailes.customerId), numberOfItems = OrderDetailes.numberOfItems, deliveryStatusStatusId = new Guid("33E0B0A3-4652-4AB7-9553-1E39767E9077"), orderStatusStatusId = new Guid("33E0B0A3-4652-4AB7-9553-1E39767E9077"), orderCreationDate = DateTime.Now }; await applicationDbContext.orders.AddAsync(order); await applicationDbContext.SaveChangesAsync(); List <Item> AllOrderItems = applicationDbContext.items.Where(I => I.orderId == order.orderId).ToList(); AddItemApiModel.Response rsulte = new AddItemApiModel.Response { orderId = order.orderId.ToString(), Items = AllOrderItems.Select(i => new AddItemApiModel.itemView { itemId = i.itemId.ToString(), itemPrice = i.totalPriceOfTheItem, printingShopID = i.printingShopId.ToString() } ).ToList(), }; return(rsulte); } else { Order order = new Order { orderId = new Guid(OrderDetailes.orderId), CustomerId = new Guid(OrderDetailes.customerId), total = OrderDetailes.totalPriceOfTheItem }; applicationDbContext.orders.Update(order); await applicationDbContext.SaveChangesAsync(); List <Item> AllOrderItems = applicationDbContext.items.Where(I => I.orderId == order.orderId).ToList(); AddItemApiModel.Response rsulte = new AddItemApiModel.Response { orderId = order.orderId.ToString(), Items = AllOrderItems.Select(i => new AddItemApiModel.itemView { itemId = i.itemId.ToString(), itemPrice = i.totalPriceOfTheItem, printingShopID = i.printingShopId.ToString() } ).ToList(), }; return(rsulte); } }