Пример #1
0
        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 IActionResult ViewOrderItems()
 {
     return(View(repo.GetList()));
 }
Пример #3
0
        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);
            }
        }