public ActionResult getOrderProductStore(int id) { try { OrderProductStores orderProductStores = _orderProductStoresService.Get(_ => _.Id == id); List <OrderProductDetails> orderProductDetails = _orderProductDetailsService.GetMany(_ => _.OrderProductStoreId == orderProductStores.Id).ToList(); orderProductDetails.ForEach(_ => { Products product = _productsService.Get(__ => __.Id == _.ProductId); _.Product = product; }); Orders order = _ordersService.Get(_ => _.Id == orderProductStores.OrderId); Addresses address = _addressesService.Get(_ => _.Id == order.AddressId); OrderProductStoreGetModel orderProductStoreGetModel = new OrderProductStoreGetModel { Id = orderProductStores.Id, Date = orderProductStores.Date, Note = orderProductStores.Note, /* Order = order,*/ Address = address, OrderProductDetails = orderProductDetails, /* OrderStatus = orderProductStores.OrderStatus, * Total = orderProductStores.Total*/ }; return(Ok(orderProductStoreGetModel)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult update(int id, DateTime date, string note, string orderId, string orderStatus, string storeID, int total) { try { OrderProductStores orderProductStores = _orderProductStoresService.Get(_ => _.Id == id); if (orderProductStores == null) { throw new Exception(); } orderProductStores.Date = date; orderProductStores.Note = note; orderProductStores.OrderId = orderId; orderProductStores.OrderStatus = orderStatus; orderProductStores.StoreId = storeID; orderProductStores.Total = total; _orderProductStoresService.Update(orderProductStores); _orderProductStoresService.SaveChanges(); return(StatusCode(204)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult create(DateTime date, string note, string orderId, string orderStatus, string storeID, int total) { try { OrderProductStores orderProductStores = new OrderProductStores { Date = date, Note = note, OrderId = orderId, OrderStatus = orderStatus, StoreId = storeID, Total = total }; _orderProductStoresService.Add(orderProductStores); _orderProductStoresService.SaveChanges(); return(Ok(orderProductStores.Id)); } catch (Exception e) { return(BadRequest(e.Message)); } }