// GET: Admin/ProductGroup/Create
        public ActionResult Create()
        {
            var viewModel = new ProductGroupViewModel();

            viewModel.Status = true;
            return(View(viewModel));
        }
 public ActionResult Create(ProductGroupViewModel viewModel)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             AccountViewModel account = Session["Account"] as AccountViewModel;
             viewModel.Description = viewModel.Description ?? String.Empty;
             viewModel.CreatedDate = DateTime.Now;
             viewModel.Creator     = account.UserName;
             viewModel.ModifyDate  = DateTime.Now;
             viewModel.Modifier    = account.UserName;
             viewModel.Url         = Extentions.ToUnsignLinkString(viewModel.GroupName);
             _iProductGroupService.InsertProductGroup(viewModel);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(viewModel));
         }
     }
     catch
     {
         return(View());
     }
 }
 public bool Change(ProductGroupViewModel entity)
 {
     using (var repository = _sourceFactory.CreateRepository <Entity.ProductGroup, int>())
     {
         return(repository.Change(new ProductGroup(entity.GroupId, entity.GroupName, entity.GroupDescription, entity.CategoryId)));
     }
 }
 public ActionResult Edit(string progroupid, ProductGroupViewModel viewModel)
 {
     try
     {
         // TODO: Add update logic here
         Guid g = Guid.Parse(progroupid);
         if (ModelState.IsValid)
         {
             AccountViewModel account = Session["Account"] as AccountViewModel;
             viewModel.Id          = g;
             viewModel.Description = viewModel.Description ?? String.Empty;
             viewModel.ModifyDate  = DateTime.Now;
             viewModel.Modifier    = account.UserName;
             viewModel.Url         = Extentions.ToUnsignLinkString(viewModel.GroupName);
             _iProductGroupService.UpdateProductGroup(viewModel);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(viewModel));
         }
     }
     catch
     {
         return(View());
     }
 }
示例#5
0
        public async Task <IActionResult> Edit(int id, ProductGroupViewModel productGroupViewModel)
        {
            if (id != productGroupViewModel.ProductGroupId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var productGroupsModel = _mapper.Map <ProductGroup>(productGroupViewModel);
                    _productGroupRepository.UpdateEntity(productGroupsModel);
                    _productGroupRepository.Save();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductGroupExists(productGroupViewModel.ProductGroupId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productGroupViewModel));
        }
示例#6
0
        public IActionResult Index(int page = 1, string keywordForSearch = "", bool isUpdate = false)
        //public async Task<IActionResult> Index(int page = 1, string keywordForSearch = "", bool isUpdate = false)
        {
            #region Check Login

            if (!_loginService.CheckLoginStatus())
            {
                return(Redirect("/Backend/Login/Index"));
            }

            #endregion

            ProductGroupViewModel productGroupViewModel = new ProductGroupViewModel();

            try
            {
                _productGroupService.GetProductGroupList(ref productGroupViewModel, keywordForSearch, isUpdate, page);

                // Bind Model to Paging Model
                productGroupViewModel.ProductGroupPagingList = PagingList.Create(productGroupViewModel.ProductGroupList, 10, page);
                //  ViewBag.keywordForSearch = productGroupViewModel.keywordForSearch;
            }

            catch (Exception exception)
            {
            }

            return(View(productGroupViewModel));
        }
示例#7
0
        public ViewProductGroup()
        {
            InitializeComponent();
            ProductGroupViewModel _PGVM = new ProductGroupViewModel();

            _PGVM.GetProductGroupList();
            this.DataContext = _PGVM;
        }
示例#8
0
        public ProductGroup()
        {
            InitializeComponent();

            ProductGroupViewModel pgvm = new ProductGroupViewModel();

            this.DataContext = pgvm;
        }
示例#9
0
        public ViewResult Edit(int?Id)
        {
            SelectList categorylist = new SelectList(_categoryViewService.ViewAll(), "Id", "CategoryName");

            ViewBag.Categories = categorylist;
            ProductGroupViewModel group = Id != null?_groupViewService.ViewSingle(Convert.ToInt32(Id.ToString())) : new ProductGroupViewModel();

            return(View(group));
        }
示例#10
0
        public ViewResult Edit(int?GroupId)
        {
            SelectList categorylist = new SelectList(categories, "CategoryId", "CategoryName");

            ViewBag.Categories = categorylist;
            ProductGroupViewModel group = groups.FirstOrDefault(c => c.GroupId == GroupId);

            return(View(group));
        }
示例#11
0
        public ProductGroupView(TillDivisionGroupDepartmentModel tillDivisionGroupDepartmentModel)
        {
            InitializeComponent();
            DataContext = ViewModel = new ProductGroupViewModel(tillDivisionGroupDepartmentModel);

            ViewModel.PropertyChanged += ViewModelOnPropertyChanged;

            Loaded += OnViewLoaded;
        }
示例#12
0
        public ProductGroupsController(ApplicationDbContext context)
        {
            _context = context;

            ProductGroupVM = new ProductGroupViewModel()
            {
                Categories   = _context.Category.ToList(),
                ProductGroup = new ProductGroup()
            };
        }
示例#13
0
 public async Task <IActionResult> Create(ProductGroupViewModel productGroupViewModel)
 {
     if (ModelState.IsValid)
     {
         var productGroupsModel = _mapper.Map <ProductGroup>(productGroupViewModel);
         _productGroupRepository.InsertEntity(productGroupsModel);
         _productGroupRepository.Save();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(productGroupViewModel));
 }
示例#14
0
 public void UpdateProductGroup(ProductGroupViewModel viewModel)
 {
     SqlDb_Ultis.ExeNonStored("Tbl_ProductGroupUpDate",
                              "@Id", viewModel.Id,
                              "@GroupName", viewModel.GroupName,
                              "@Description", viewModel.Description,
                              "@Status", viewModel.Status,
                              "@Modifier", viewModel.Modifier,
                              "@ModifyDate", viewModel.ModifyDate,
                              "@Url", viewModel.Url);
 }
示例#15
0
        public ProductGroupViewModel GetProductGroupById(Guid Id)
        {
            DataTable             dtb  = SqlDb_Ultis.ExeStoredToDataTable("Tbl_ProductGroupSelectByID", "@Id", Id);
            ProductGroupViewModel role = new ProductGroupViewModel();

            foreach (DataRow item in dtb.Rows)
            {
                role = Ultis.GetItem <ProductGroupViewModel>(item);
            }
            return(role);
        }
        public static ProductGroupViewModel ConvertToProductGroupViewModel(ecom_ProductGroups group)
        {
            var returnModel = new ProductGroupViewModel()
            {
                Id          = group.Id,
                Name        = group.Name,
                Status      = (int)group.Status,
                Description = group.Description
            };

            return(returnModel);
        }
        /// <summary>
        /// Delete Product Group.
        /// </summary>
        // Author: Mod Nattasit
        // Updated: 07/07/2019
        public void DeleteProductGroup(ProductGroupViewModel productGroupViewModel)
        {
            #region Create Object to Delete

            ProductGroup productGroup = new ProductGroup()
            {
                Id = productGroupViewModel.Id,
            };

            #endregion

            _unitOfWork.ProductGroups.Remove(productGroup);
        }
示例#18
0
        /// <summary>
        /// Update Table.
        /// </summary>
        // Author: Mod Nattasit
        // Updated: 07/07/2019
        public PartialViewResult UpdateTable()
        {
            ProductGroupViewModel productGroupViewModel = new ProductGroupViewModel();

            try
            {
                _productGroupService.GetProductGroupList(ref productGroupViewModel, string.Empty, false, 1);
            }
            catch (Exception exception)
            {
            }

            return(PartialView("_Table", productGroupViewModel));
        }
示例#19
0
 private void FilterByProductGroup(ProductGroupViewModel data)
 {
     if (data == null)
     {
         this.productListComponent.ProductListView.ItemsSource = this.productListComponent.productFiltered;
         this.productListComponent.productCaption.Text         = "Products";
     }
     else
     {
         this.productListComponent.productFiltered             = new ObservableCollection <ProductViewModel>(this.productListComponent.product.Where(a => a.ProductGroupId == data.Id));
         this.productListComponent.productCaption.Text         = $"Products : {data.Name}";
         this.productListComponent.ProductListView.ItemsSource = this.productListComponent.productFiltered;;
     }
 }
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            var newGroup = new ProductGroupViewModel()
            {
                Name        = txtName.Text.Trim(),
                Description = txtDescription.Text.Trim()
            };

            if (string.IsNullOrWhiteSpace(newGroup.Name))
            {
                return;
            }

            manager.CreateAndSave(newGroup);
        }
示例#21
0
        public JsonResult GetProductPriceByQuantity(string productGroupCode, int quantity)
        {
            ProductGroupViewModel productGroupViewModel = new ProductGroupViewModel();

            try
            {
                _homeService.GetProductPriceByQuantity(ref productGroupViewModel, productGroupCode, quantity);
            }
            catch (Exception exception)
            {
                throw;
            }

            return(Json(productGroupViewModel));
        }
示例#22
0
        public ActionResult Delete(int Id)
        {
            ProductGroupViewModel foundGroup = _groupViewService.ViewAll().FirstOrDefault(c => c.Id == Id);

            if (foundGroup != null)
            {
                _groupModifyService.Delete(foundGroup.Id);
                TempData["message"] = string.Format("Product group  was deleted");
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["message"] = string.Format("Product group was not found");
            }
            return(RedirectToAction("Index"));
        }
示例#23
0
        public async Task <ProductGroupViewModel> Search(UserProfile user, string name, string path = null)
        {
            var businessTask = Task.Run(() => businessRepo.GetByIdAsync(user.business_id.Value));
            var fillerTask   = Task.Run(() => foldersDs.GetTreeAsync(user.business_id.Value));

            var(tree, business) = await Tasker.WhenAll(fillerTask, businessTask);

            var bname = business.id + ". " + business.name;

            var prodGroup = new ProductGroupViewModel();
            Tree <ImgTwinModel>        subTree = null;
            IEnumerable <ImgTwinModel> result  = new List <ImgTwinModel>();

            if (!string.IsNullOrEmpty(path))
            {
                subTree = foldersDs.SearchSubTree(path);
            }

            if (!string.IsNullOrEmpty(name))
            {
                result = foldersDs.Search(subTree ?? foldersDs.Tree, name);
            }
            //result = result.Where(p => p.fullpath.Split('/')[2] == bname).ToList();

            //get folders from result
            prodGroup.Folders = result.Where(p => p.isFolder)
                                .Select(p => new FolderViewModel {
                id = p.id, folder = p.folder, fullpath = p.fullpath
            }).ToList();

            //get products from result
            var pics = result.Where(p => p.isFile)
                       .Select(p => new ProductViewModel {
                Id = p.id
            }).OrderBy(p => p.Id).ToList();

            if (pics.Any())
            {
                prodGroup.Products = new List <ProductViewModel>();
                foreach (var productViewModel in pics)
                {
                    prodGroup.Products.Add(await productService.GetProduct(user, productViewModel.Id));
                }
            }

            return(prodGroup);
        }
示例#24
0
        public IActionResult Save(ProductGroupViewModel productGroupViewModel)
        {
            bool   isSuccess;
            string exceptionMessage = string.Empty;

            try
            {
                _productGroupService.SaveProductGroup(productGroupViewModel);
                isSuccess = true;
            }
            catch (Exception exception)
            {
                exceptionMessage = exception.Message;
                isSuccess        = false;
            }

            return(Json(new { isSuccess = isSuccess, exceptionMessage = exceptionMessage }));
        }
示例#25
0
        public async Task <ProductGroupViewModel> GetNexLevelGroup(UserProfile user, string fullpath = null, bool needProducts = true)
        {
            var prodGroup    = new ProductGroupViewModel();
            var businessTask = Task.Run(() => businessRepo.GetByIdAsync(user.business_id.Value));
            var fillerTask   = Task.Run(() => foldersDs.GetTreeAsync(user.business_id.Value));

            var(tree, business) = await Tasker.WhenAll(fillerTask, businessTask);

            IEnumerable <ImgTwinModel> level = new List <ImgTwinModel>();

            if (string.IsNullOrEmpty(fullpath))
            {
                level = foldersDs.GetLevel("/" + business.name);
            }
            else
            {
                level = foldersDs.GetLevel(fullpath);
            }

            prodGroup.Folders = level.Where(p => p.isFolder)
                                .Select(p => new FolderViewModel {
                id = p.id, folder = p.folder, fullpath = p.fullpath
            }).ToList();

            if (needProducts)
            {
                var pics = level.Where(p => p.isFile)
                           .Select(p => new ProductViewModel {
                    Id = Convert.ToInt32(p.folder.Split('.')[0])
                }).OrderBy(p => p.Id).ToList();

                if (pics.Any())
                {
                    prodGroup.Products = new List <ProductViewModel>();
                    foreach (var productViewModel in pics)
                    {
                        prodGroup.Products.Add(await productService.GetProduct(user, productViewModel.Id));
                    }
                }
            }

            return(prodGroup);
        }
        /// <summary>
        /// Get Product Group List.
        /// </summary>
        // Author: Mod Nattasit
        // Updated: 07/07/2019
        public void GetProductGroupList(ref ProductGroupViewModel productGroupViewModel, string keywordForSearch, bool isUpdate, int page)
        {
            if (!isUpdate)
            {
                #region Check Keyword for Search from Session

                if (keywordForSearch == string.Empty && (_httpContextAccessor.HttpContext.Session.GetString("KeywordForSearch") != null && _httpContextAccessor.HttpContext.Session.GetString("KeywordForSearch") != string.Empty))
                {
                    keywordForSearch = _httpContextAccessor.HttpContext.Session.GetString("KeywordForSearch");
                    productGroupViewModel.keywordForSearch = keywordForSearch;
                }

                #endregion
            }
            else
            {
                if (keywordForSearch == "")
                {
                    _httpContextAccessor.HttpContext.Session.Remove("KeywordForSearch");
                }
            }


            #region Get List

            //productGroupViewModel.ProductGroupList = _unitOfWork.ProductGroups.GetAll();
            productGroupViewModel.ProductGroupList = _unitOfWork.ProductGroups.GetBySearch(keywordForSearch);
            productGroupViewModel.StartNoOfTable   = ((page - 1) * 10) + 1;

            _httpContextAccessor.HttpContext.Session.SetString("KeywordForSearch", keywordForSearch);
            productGroupViewModel.keywordForSearch = keywordForSearch;
            #endregion

            #region Get Select List

            productGroupViewModel.ProductCategorieSelectList = _unitOfWork.ProductCategories.GetAll().Select(s => new SelectListItem {
                Value = s.Code, Text = s.Name
            });

            #endregion
        }
        /// <summary>
        /// Save Product Group.
        /// </summary>
        // Author: Mod Nattasit
        // Updated: 07/07/2019
        public void SaveProductGroup(ProductGroupViewModel productGroupViewModel)
        {
            #region Create Object to Save

            ProductGroup productGroup = new ProductGroup()
            {
                Code                 = productGroupViewModel.Code,
                Name                 = productGroupViewModel.Name,
                UnitPrice            = productGroupViewModel.UnitPrice,
                PromotionPrice       = productGroupViewModel.PromotionPrice,
                MinQuantity          = productGroupViewModel.MinQuantity,
                MaxQuantity          = productGroupViewModel.MaxQuantity,
                IsActive             = true,
                ProductCategorieCode = productGroupViewModel.ProductCategorieCode,
                CreatedDateTime      = DateTime.Now
            };

            #endregion

            _unitOfWork.ProductGroups.Add(productGroup);
        }
示例#28
0
 public ActionResult Edit(ProductGroupViewModel group)
 {
     if (ModelState.IsValid)
     {
         if (groups.Any(c => c.GroupId == group.GroupId))
         {
             _db.ProductGroup.Change(group);
             TempData["message"] = string.Format("Group \"{0}\"uploaded", group.GroupName);
         }
         else
         {
             _db.ProductGroup.Add(group);
             TempData["message"] = string.Format("Group\"{0}\"added", group.GroupName);
         }
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(group));
     }
 }
        /// <summary>
        /// Update Product Group.
        /// </summary>
        // Author: Mod Nattasit
        // Updated: 07/07/2019
        public void UpdateProductGroup(ProductGroupViewModel productGroupViewModel)
        {
            #region Create Object to Update

            ProductGroup productGroup = new ProductGroup()
            {
                Id                   = productGroupViewModel.Id,
                Code                 = productGroupViewModel.Code,
                Name                 = productGroupViewModel.Name,
                UnitPrice            = productGroupViewModel.UnitPrice,
                PromotionPrice       = productGroupViewModel.PromotionPrice,
                MinQuantity          = productGroupViewModel.MinQuantity,
                MaxQuantity          = productGroupViewModel.MaxQuantity,
                ProductCategorieCode = productGroupViewModel.ProductCategorieCode,
                CreatedDateTime      = productGroupViewModel.CreatedDateTime,
                UpdatedDateTime      = DateTime.Now
            };

            #endregion

            _unitOfWork.ProductGroups.Update(productGroup);
        }
示例#30
0
        public ActionResult ShowCategory()
        {
            var model = new List <ProductGroupViewModel>();

            var groupList = db.ProductGroups.Where(w => w.ParentId == null && (w.IsDeleted == false || w.IsDeleted == null)).ToList();

            groupList.ForEach(item =>
            {
                var GroupHeader     = new ProductGroupViewModel();
                GroupHeader.Title   = item.GroupName;
                GroupHeader.GroupId = item.Id;

                var subGroupList = db.ProductGroups.Where(w => w.ParentId == item.Id && w.IsDeleted != true).ToList();

                subGroupList.ForEach(subItem =>
                {
                    var Groups     = new ProductGroupViewModel();
                    Groups.Title   = subItem.GroupName;
                    Groups.GroupId = subItem.Id;

                    var subItemGroupList = db.ProductGroups.Where(w => w.ParentId == subItem.Id && w.IsDeleted != true).ToList();

                    subItemGroupList.ForEach(sub =>
                    {
                        var subgroup     = new ProductGroupViewModel();
                        subgroup.GroupId = sub.Id;
                        subgroup.Title   = sub.GroupName;

                        Groups.SubGroups.Add(subgroup);
                    });

                    GroupHeader.SubGroups.Add(Groups);
                });

                model.Add(GroupHeader);
            });
            return(PartialView(model));
        }