Ejemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            ProductsInPosViewModel pb = new ProductsInPosViewModel();

            InfoFormat("Selecting products for POS #{0}", id);
            pb.Pos = _organizationRepository.GetById(id);
            pb.Products = _productRepository.Products
                .Where(x => x.PosId == id && x.StatusId == (byte)Status.Approved)
                .Take(100)
                .Select(x => new Models.Product {

                })
                .ToList();
            pb.Organizations = _organizationRepository.Organizations.ToList();
            return View(pb);
        }
Ejemplo n.º 2
0
        //
        // GET: /pradmin/list/100003
        public ActionResult List(int id)
        {
            ProductsInPosViewModel productsList = new ProductsInPosViewModel();
            productsList.Pos = _organizationRepository.Organizations.SingleOrDefault(x => x.Id == id);
            if( productsList.Pos == null )
            {
                ErrorFormat("Trying to list products in non-existing POS #{0}!", id);
                return HttpNotFound();
            }

            //productsList.Categories = _productRepository.Categories.Select(x => new CategoryListItem(null)).ToList();

            //productsList.Categories = _productRepository.Categories
            //    .Where(x => x.OrganizationId == productsList.Pos.Id)
            //    .Select(x => new CategoryListItem(x))
            //    //.Select(x => new OnBalance.Models.Category {
            //    //    Id = x.Id,
            //    //    Name = x.Name,
            //    //    OrganizationId = x.OrganizationId,
            //    //    ParentId = x.ParentId,
            //    //    StatusId = x.StatusId,
            //    //    CategoryTypeId = x.CategoryTypeId,
            //    //})
            //    .ToList();

            int perPage = 50;
            int page = 0;
            if( int.TryParse(Request["p"], out page) == false )
            {
                page = 1;
            }
            int offset = (page - 1) * perPage;

            InfoFormat("Displaying list of products in POS #{0}, skipping {1}, taking {2} products", id, offset, perPage);
            productsList.Products = _productRepository.GetLastInPos(id, offset, perPage)
                .OrderBy(x => x.Id)
                .Select(x => new OnBalance.Models.Product
                {
                    Id = x.Id,
                    Name = x.Name,
                    PosId = x.PosId,
                    Price = x.Price,
                    StatusId = x.StatusId,
                    InternalCode = x.InternalCode,
                    CategoryId = x.CategoryId,
                    Uid = x.Uid,
                    UserId = x.UserId,
                    Pos = new OnBalance.Domain.Entities.Organization { Configuration = new OnBalance.Domain.Entities.OrganizationConfiguration() }
                })
                .ToList();
            DebugFormat("  got {0} products...", productsList.Products.Count);

            return View("List", Layout, productsList);
        }