public OrdersController() { _ordersRepository = new OrdersRepository(); _menuItemRepository = new MenuItemRepository(); _orderItemsRepository = new OrderItemsRepository(); _validator = new OrdersRequestValidator(); }
public override object OnDelete(Orders request) { var orderItems = OrderItemsRepository.ForOrderId(new Guid(request.Id)).ToList(); if (orderItems.Count == 0) { return new HttpResult { StatusCode = (HttpStatusCode)422, StatusDescription = "No order found for the given identifier." } } ; // BUG: If more than one order items are contained in the order, it can 't be deleted. if (orderItems.Count > 1) { return new HttpResult { StatusCode = HttpStatusCode.OK } } ; orderItems.ForEach(x => OrderItemsRepository.Delete(x.Id.GetValueOrDefault())); OrdersRepository.Delete(new Guid(request.Id)); return(new HttpResult { StatusCode = HttpStatusCode.OK }); } } }
public OrderService(CustomerRepository customerRepository, OrderValueRepository orderValueRepository, OrdersRepository ordersRepository, OrderItemsRepository orderItemsRepository) { this.customerRepository = customerRepository; this.orderValueRepository = orderValueRepository; this.ordersRepository = ordersRepository; this.orderItemsRepository = orderItemsRepository; }
public JsonResult AjaxCreate(Orders_Items orderItem) { if (Authorized(RoleType.OrdersWriter)) { bool wasCreated; using (OrderItemsRepository itemRep = new OrderItemsRepository(CurrentUser.CompanyId, orderItem.SupplierId)) { wasCreated = itemRep.Create(orderItem); } if (wasCreated) return Json(new { success = true, message = String.Empty, newItemId = orderItem.Id }, JsonRequestBehavior.AllowGet); else return Json(new { success = false, message = Loc.Dic.error_supplier_item_create_error }, JsonRequestBehavior.AllowGet); } else { return Json(new { success = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet); } }
public JsonResult GetBySupplier(int?id = null) { if (Authorized(RoleType.OrdersWriter)) { List <AjaxOrderItem> allItems; using (OrderItemsRepository itemRep = new OrderItemsRepository(CurrentUser.CompanyId, id)) { if (id.HasValue) { allItems = itemRep.GetList().Where(item => item.SupplierId == id && item.CompanyId == CurrentUser.CompanyId).Select(x => new AjaxOrderItem() { Id = x.Id, Title = x.Title, SubTitle = x.SubTitle }).OrderBy(x => x.Title).ToList(); } else { allItems = itemRep.GetList().Where(item => item.SupplierId == null && item.CompanyId == CurrentUser.CompanyId).Select(x => new AjaxOrderItem() { Id = x.Id, Title = x.Title, SubTitle = x.SubTitle }).OrderBy(x => x.Title).ToList(); } } if (allItems != null) { return(Json(new { gotData = true, data = allItems, message = String.Empty }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { gotData = false, message = Loc.Dic.error_orderitems_get_error }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { gotData = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AjaxCreate(Orders_Items orderItem) { if (Authorized(RoleType.OrdersWriter)) { bool wasCreated; using (OrderItemsRepository itemRep = new OrderItemsRepository(CurrentUser.CompanyId, orderItem.SupplierId)) { wasCreated = itemRep.Create(orderItem); } if (wasCreated) { return(Json(new { success = true, message = String.Empty, newItemId = orderItem.Id }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = Loc.Dic.error_supplier_item_create_error }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet)); } }
public CheckoutService(CustomerRepository customerRepository, OrderItemsRepository orderItemsRepository) { this.customerRepository = customerRepository; this.orderItemsRepository = orderItemsRepository; }
public FinalOrderServices(CustomerRepository customerRepository, OrderItemsRepository orderItemsRepository) { this.customerRepository = customerRepository; this.orderItemsRepository = orderItemsRepository; }
public OrderItemsService(OrderItemsRepository orderItemsRepository) { this.orderItemsRepository = orderItemsRepository; }
public OrderItemsController(IRepository <OrderItems> r) { repo = (OrderItemsRepository)r; }
public JsonResult GetBySupplier(int? id = null) { if (Authorized(RoleType.OrdersWriter)) { List<AjaxOrderItem> allItems; using (OrderItemsRepository itemRep = new OrderItemsRepository(CurrentUser.CompanyId, id)) { if(id.HasValue) allItems = itemRep.GetList().Where(item => item.SupplierId == id && item.CompanyId == CurrentUser.CompanyId).Select(x => new AjaxOrderItem() { Id = x.Id, Title = x.Title, SubTitle = x.SubTitle }).OrderBy(x => x.Title).ToList(); else allItems = itemRep.GetList().Where(item => item.SupplierId == null && item.CompanyId == CurrentUser.CompanyId).Select(x => new AjaxOrderItem() { Id = x.Id, Title = x.Title, SubTitle = x.SubTitle }).OrderBy(x => x.Title).ToList(); } if (allItems != null) { return Json(new { gotData = true, data = allItems, message = String.Empty }, JsonRequestBehavior.AllowGet); } else { return Json(new { gotData = false, message = Loc.Dic.error_orderitems_get_error }, JsonRequestBehavior.AllowGet); } } else { return Json(new { gotData = false, message = Loc.Dic.error_no_permission }, JsonRequestBehavior.AllowGet); } }