Ejemplo n.º 1
0
        protected ApiProductsListResponse GetProductsInPos(int posId, OnBalance.Models.ApiRequestParameters rp)
        {
            ApiProductsListResponse resp = new ApiProductsListResponse();

            if (posId < 1)
            {
                ErrorFormat("Bad ID of POS (ID: {0}) to retrieve products!", posId);
                resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.BadRequest);
            }

            var pos = _organizationRepository.GetById(posId);

            if (pos == null)
            {
                ErrorFormat("Could not retrieve products for non-existing POS (ID: {0})!", posId);
                resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.NotFound);
                resp.message = MyMessages.Products.PosIsNotFound;
                return(resp);
            }

            rp.SetLimitIfNotPositive(10);
            InfoFormat("API: getting list of product in POS #{0}, parameters: {1}", posId, rp);
            var products = _productRepository.GetLastInPos(posId, rp.Offset, rp.Limit);

            resp.products = products.ToList();

            return(resp);
        }
Ejemplo n.º 2
0
        protected ApiPosListReponse GetListOfPos(OnBalance.Models.ApiRequestParameters rp)
        {
            ApiPosListReponse resp = new ApiPosListReponse();

            rp.SetLimitIfNotPositive(10);
            //if(rp.ParentId > 0)
            //{
            //    resp.listOfPos = new OrganizationRepository().GetByParentId(rp.ParentId);
            //    resp.message = string.Concat("List of POS by parent ", rp.ParentId);
            //    InfoFormat("Got list of POS by parent ID: {0}, offset {1}, limit: {2}. Total POS are {3}", rp.ParentId, rp.Offset, rp.Limit, resp.total);
            //} else
            //{
            //    resp.listOfPos = new OrganizationRepository().GetListOfLastPos(rp.Offset, rp.Limit);
            //    InfoFormat("Got list of POS, offset {0}, limit: {1}. Total POS are {2}", rp.Offset, rp.Limit, resp.total);
            //}
            resp.listOfPos = _organizationRepository.GetByParentId(rp.ParentId, true);
            resp.message   = string.Concat("List of POS by parent ", rp.ParentId);
            InfoFormat("Got list of POS by parent ID: {0}, offset {1}, limit: {2}. Total POS are {3}", rp.ParentId, rp.Offset, rp.Limit, resp.total);
            resp.SetResponseCode(OnBalance.Models.ApiResponseCodes.Ok);
            return(resp);
        }