Пример #1
0
        public PurchaseOrderDetailTempListModel FindPurchaseOrderDetailTempsListModel(int companyId, int purchaseOrderHeaderTempId,
                                                                                      int index, int pageNo, int pageSize, string search,
                                                                                      string sortColumn = "", SortOrder sortOrder = SortOrder.Asc)
        {
            var model = new PurchaseOrderDetailTempListModel();

            int searchInt = 0;

            int.TryParse(search, out searchInt);

            // Do a case-insensitive search
            model.GridIndex = index;
            var allItems = db.FindPurchaseOrderDetailTemps(companyId, purchaseOrderHeaderTempId, sortColumn, sortOrder)
                           .Where(p => string.IsNullOrEmpty(search) ||
                                  (p.ProductDescription != null && p.ProductDescription.Contains(search)) ||
                                  (p.LineNumber == searchInt));

            model.TotalRecords = allItems.Count();
            foreach (var item in allItems.Skip((pageNo - 1) * pageSize)
                     .Take(pageSize))
            {
                var newItem = MapToModel(item);
                model.Items.Add(newItem);
            }

            return(model);
        }
        public ActionResult Delete(int index, int id, int parentId)
        {
            var model = new PurchaseOrderDetailTempListModel();

            model.GridIndex = index;
            try {
                PurchasingService.DeletePurchaseOrderDetailTemp(id);
            } catch (Exception e1) {
                model.Error.SetError(e1);
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        private PurchaseOrderDetailTempModel createPurchaseOrderDetailTemp(PurchaseOrderDetailTempListModel model)
        {
            // Create a new item by duplicating a randomly selected item already in the list
            // This is an easy way, otherwise we have to go looking for suppliers, products, tax codes etc
            var podt = PurchasingService.MapToModel(model.Items[RandomInt(0, model.Items.Count() - 1)]);

            podt.Id         = 0;
            podt.LineNumber = 0;
            podt.OrderQty   = RandomInt();

            return(podt);
        }