Exemple #1
0
        public IActionResult Create()
        {
            var model = new ManageProductModel()
            {
                Product      = new Product(),
                TaskStatuses = _context.TaskStatuses.ToList()
            };

            return(View("Edit", model));
        }
Exemple #2
0
        public IActionResult Edit(int productId)
        {
            var model = new ManageProductModel
            {
                Product = _context.Products.Include(x => x.Tasks).ThenInclude(x => x.Status)
                          .Single(x => x.Id == productId),
                TaskStatuses = _context.TaskStatuses.ToList()
            };

            return(View(model));
        }
        public ActionResult Index(ManageProductModel model)
        {
            int currentPage = 1;
            int pageSize    = SystemSettings.DefaultPageSize;

            if (string.IsNullOrEmpty(model.SearchExec))
            {
                model.SearchExec = "Y";
                if (!ModelState.IsValid)
                {
                    ModelState.Clear();
                }
            }

            if (Request["Page"] != null)
            {
                currentPage = Utils.ConvertToInt32(Request["Page"], 1);
            }

            var filter = new IdentityProduct
            {
                Keyword           = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null,
                Status            = model.Status == null ? -1 : (int)model.Status,
                ProductCategoryId = model.ProductCategoryId == null ? 0 : (int)model.ProductCategoryId,
                ProviderId        = model.ProviderId == null ? 0 : (int)model.ProviderId
            };

            try
            {
                model.Providers         = CommonHelpers.GetListProvider();
                model.ProductCategories = CommonHelpers.GetListProductCategory();
                model.Units             = CommonHelpers.GetListUnit();

                model.SearchResults = _mainStore.GetByPage(filter, currentPage, SystemSettings.DefaultPageSize);
                if (model.SearchResults != null && model.SearchResults.Count > 0)
                {
                    model.TotalCount  = model.SearchResults[0].TotalCount;
                    model.CurrentPage = currentPage;
                    model.PageSize    = pageSize;
                }
            }
            catch (Exception ex)
            {
                this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR);

                logger.Error("Failed to get data because: " + ex.ToString());

                return(View(model));
            }

            return(View(model));
        }