public ActionResult Create(SubCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                var subCategoryDb = this.Mapper.Map<SubCategory>(model);
                this.subCategories.Add(subCategoryDb);
                this.subCategories.SaveChanges();

                if (model.CategoryNames != null && model.CategoryNames.Count > 0)
                {
                    var categories = this.categories.All().ToList();
                    foreach (var category in categories)
                    {
                        if (model.CategoryNames.Contains(category.Name))
                        {
                            subCategoryDb.Categories.Add(category);
                        }
                    }
                }

                this.categories.SaveChanges();

                this.HttpContext.Cache.Remove("menu");
            }

            return RedirectToAction("Index");
        }
Example #2
0
        public async Task <IActionResult> Post([FromBody] SubCategoryViewModel value)
        {
            value = await service.Create(value);

            if (value == null)
            {
                return(BadRequest());
            }
            return(CreatedAtAction("Get", new { categoryId = value.CategoryId, id = value.Id }, value));
        }
        public async Task <ActionResult> CreateSubCategory()
        {
            var category = await DocumentDbRepository <Category> .GetItemsAsync(d => d != null);

            SubCategoryViewModel subCatalogViewModel = new SubCategoryViewModel();

            subCatalogViewModel.CategoryList = category;

            return(View("CreateSubCategory", subCatalogViewModel));
        }
Example #4
0
        public IActionResult Create()
        {
            var SubCategoryViewModel = new SubCategoryViewModel()
            {
                Categories  = db.Categories.ToList(),
                SubCategory = new SubCategory()
            };

            return(View(SubCategoryViewModel));
        }
Example #5
0
        public ActionResult CreateSubCategory(SubCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                _subCategoryService.Create(_mapper.Map <SubCategoryDTO>(model));
                return(RedirectToAction("Index", "Admin"));
            }

            return(View(model));
        }
Example #6
0
        public void Update(SubCategoryViewModel model)
        {
            var subCategory = new SubCategory()
            {
                Name = model.Name,
                Id   = model.Id,
            };

            _subCategoryRepository.Update(subCategory);
        }
Example #7
0
        private CategoryPage InitiateCategoryPage()
        {
            _subCategorySelectorViewModel = new SubCategoryViewModel();
            _categoryPageViewModel        = new CategoryPageViewModel(_subCategorySelectorViewModel);
            _categoryPage = new CategoryPage(_categoryPageViewModel);

            _categoryPage.SubCategorySelectionChanged += _categoryPage_SubCategorySelectionChanged;

            return(_categoryPage);
        }
Example #8
0
        public async Task <IActionResult> Put(int id, [FromBody] SubCategoryViewModel model)
        {
            model = await service.Update(id, model);

            if (model == null)
            {
                return(BadRequest());
            }
            return(Ok(model));
        }
        public ActionResult Update(int id, SubCategoryViewModel model)
        {
            var data = _subCategoryService.GetById(id);

            if (data != null)
            {
                return(HttpNotFound());
            }
            _subCategoryService.Update(model);
            return(RedirectToAction("ListOfSubCategory"));
        }
Example #10
0
        public static SubCategoryViewModel MapFromDto(this SubCategoryDto subCategoryDto)
        {
            SubCategoryViewModel subCategoryViewModel = new SubCategoryViewModel();

            subCategoryViewModel.Id            = subCategoryDto.Id;
            subCategoryViewModel.Name          = subCategoryDto.Name;
            subCategoryViewModel.Categories_Id = subCategoryDto.Categories_Id;
            subCategoryViewModel.PolicyCount   = subCategoryDto.PolicyCount;

            return(subCategoryViewModel);
        }
        public ActionResult Create()
        {
            SubCategoryViewModel subcategoryViewModel = new SubCategoryViewModel();

            subcategoryViewModel.CategoryList = _categoryBusiness.GetListWT().Select(x => new SelectListItem
            {
                Text  = x.CategoryName.ToString(),
                Value = x.CategoryId.ToString()
            }).ToList();
            return(View(subcategoryViewModel));
        }
        public IActionResult SubCategory(int id)
        {
            SubCategoryViewModel subCategoryViewModel = new SubCategoryViewModel();

            if (id != 0)
            {
                subCategoryViewModel.subCategories = SubCategoryRepository.GetAllSubCategoryOfCategory(id);
                subCategoryViewModel.category      = CategoryRepository.GetCategory(subCategoryViewModel.subCategories.ToList()[0].CategoryId);
            }
            return(View(subCategoryViewModel));
        }
        public void Publish(SubCategoryViewModel vm)
        {
            var ctxSubCategory = _ctx.SubCategories.FirstOrDefault(c => c.Id.Equals(vm.Id));

            if (ctxSubCategory != null)
            {
                ctxSubCategory.Id        = vm.Id;
                ctxSubCategory.Published = vm.Published;
            }
            _ctx.SaveChanges();
        }
Example #14
0
        public void Create(SubCategoryViewModel SubCategoryViewModel)
        {
            var SubCategory = new SubCategory
            {
                SubCategoryName = SubCategoryViewModel.SubCategoryName,
                CategoryId      = SubCategoryViewModel.CategoryId
            };

            unitOfWork.SubCategoryRepository.Insert(SubCategory);
            unitOfWork.Save();
        }
Example #15
0
        public IActionResult SubCategories(SubCategoryViewModel model)
        {
            categoryService.InsertAsync(new SubCategory
            {
                CategoryId    = model.CategoryId,
                DescriptionAZ = model.DescriptionAZ,
                DescriptionRU = model.DescriptionRU
            });

            return(RedirectToAction("SubCategories"));
        }
        private void GridSubCategory_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            bool ok = false;

            SubCategoryVO cat = e.Row.DataContext as SubCategoryVO;

            _cvm             = (SubCategoryViewModel)ViewModel;
            cat.ModifiedDate = DateTime.Now;

            ok = _cvm.ManageSave(cat);
        }
        /// <summary>
        /// Edit Sub Category Data
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Edit(int id)
        {
            SubCategoryViewModel model = await generateAPIResponse.SubCategoryViewRepo.GetByID("subcategory", id);

            if (model != null)
            {
                GetCategories();
                return(View("Create", model));
            }
            return(RedirectToAction("Index"));
        }
Example #18
0
        public ActionResult AddEditSubCategory(SubCategoryViewModel model, HttpPostedFileBase file)
        {
            var res = AutoMapper.Mapper.Map <SubCategoryViewModel, SubCategoryMaster>(model);

            if (file != null)
            {
                res.ImageURL = UploadFileOnServer(SubCategoryImagePath, file);
            }
            var isSuccess = _subCategoryService.AddOrUpdateSubCategory(res);

            return(Json(isSuccess, JsonRequestBehavior.AllowGet));
        }
Example #19
0
        public async Task <IActionResult> Create([Bind("SubCategoryViewModelId,Name,MainCategoryViewModelId")] SubCategoryViewModel subCategoryViewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subCategoryViewModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MainCategoryViewModelId"] = new SelectList(_context.MainCategoryViewModel, "MainCategoryViewModelId", "MainCategoryViewModelId", subCategoryViewModel.MainCategoryViewModelId);
            return(View(subCategoryViewModel));
        }
Example #20
0
        public ActionResult EditSubCategory(string SubCategoryName, string SubCategoryId, string SubCategoryRemark, string CategoryId, int id)
        {
            SubCategoryViewModel model = new SubCategoryViewModel();

            model.Id                = id;
            model.SubCategoryId     = SubCategoryId;
            model.CategoryId        = CategoryId;
            model.SubCategoryName   = SubCategoryName;
            model.SubCategoryRemark = SubCategoryRemark;
            service.EditSubCategory(model);
            return(RedirectToAction("SubCategoryConfig", "Manage", new { id = CategoryId }));
        }
Example #21
0
        // GET: Category/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            HttpResponseMessage  response    = client.GetAsync(BaseUrl + "api/subcategories/" + id).Result;
            SubCategoryViewModel subcategory = await response.Content.ReadAsAsync <SubCategoryViewModel>();

            HttpResponseMessage      resp       = client.GetAsync(BaseUrl + "api/categories").Result;
            List <CategoryViewModel> categories = await resp.Content.ReadAsAsync <List <CategoryViewModel> >();

            ViewBag.Categories = categories;

            return(View(subcategory));
        }
Example #22
0
        public void Update(SubCategoryViewModel model)
        {
            var subCategory = _subcategoryRepository.FindById(model.ID);

            if (subCategory == null)
            {
                throw new ApplicationException("SubCategory not found.");
            }

            subCategory.Name       = model.Name;
            subCategory.CategoryId = model.CategoryId;
            _subcategoryRepository.Update(subCategory);
        }
Example #23
0
        public IActionResult Index()
        {
            ViewBag.EntityType = "SubCategory";

            var subCatVm = new SubCategoryViewModel
            {
                SubCategories   = subCatrepo.GetAll(),
                Categories      = catRepo.GetAll(),
                AttributeGroups = attrGroupRepo.GetAll()
            };

            return(View(subCatVm));
        }
Example #24
0
 public IHttpActionResult Save(SubCategoryViewModel viewModel)
 {
     try
     {
         var model  = Mapper.Map <SubCategoryViewModel, SubCategory>(viewModel);
         var result = _app.Save(model);
         return(Ok(result));
     }
     catch
     {
         return(BadRequest("Error while saving Sub Category"));
     }
 }
Example #25
0
 public IHttpActionResult Remove(SubCategoryViewModel viewModel)
 {
     try
     {
         var model = Mapper.Map <SubCategoryViewModel, SubCategory>(viewModel);
         _app.Remove(model);
         return(Ok());
     }
     catch
     {
         return(BadRequest("Error while deleting Sub Category"));
     }
 }
        /// <summary>
        /// Show Sub Category Details
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> Details(int id)
        {
            SubCategoryViewModel model = await generateAPIResponse.SubCategoryViewRepo.GetByID("subcategory", id);

            if (model != null)
            {
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #27
0
        public async Task <IActionResult> SubCategories()
        {
            var categories = await categoryService.GetAllCategories();

            var model = new SubCategoryViewModel
            {
                Categories = categories.Select(x =>
                                               new SelectListItem(x.DescriptionAZ + " - " + x.DescriptionRU, x.Id.ToString()))
                             .ToList()
            };

            return(View(model));
        }
Example #28
0
        // GET: Admin/SubCategories/Create
        public IActionResult Create()
        {
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id");

            SubCategoryViewModel model = new SubCategoryViewModel
            {
                CategoryList    = _context.Categories.ToList(),
                SubCategory     = new SubCategory(),
                SubCategoryList = _context.SubCategories.OrderBy(i => i.Name).Select(i => i.Name).ToList <string>(),
            };

            return(View(model));
        }
Example #29
0
 public IHttpActionResult GetFields(SubCategoryViewModel subCategory)
 {
     try
     {
         var          model  = Mapper.Map <SubCategory>(subCategory);
         List <Field> fields = _app.GetFields(model);
         return(Ok(Mapper.Map <List <FieldViewModel> >(fields)));
     }
     catch
     {
         return(BadRequest("Error while removing Field"));
     }
 }
Example #30
0
        public async Task <ActionResult> Update(int id)
        {
            var SubCategory = await _SubCategoryrepo.GetSubCategoryById(id);


            var model = new SubCategoryViewModel()
            {
                Categories  = await _Categoryrepo.GetAllCategory(),
                SubCategory = SubCategory
            };

            return(View("SubCategoryForm", model));
        }
        public void loadAll()
        {
            SubCategoryViewModel objSubCategory = new SubCategoryViewModel();
            CategoryViewModel    objCategory    = new CategoryViewModel();
            int i = 0;

            var ProcurementTypeList = ProcrurementTypeServices.GetAll();

            ViewBag.ProcurementTypeList = new SelectList(ProcurementTypeList, "ProcurementTypeId", "ProcurementTypeName");

            var SuplierCompanyList = SupplierCompanyServices.GetAll();

            ViewBag.SuplierCompanyList = new SelectList(SuplierCompanyList, "SupplierCompanyId", "SupplierCompanyName");

            var Itemlist = ItemServices.GetAll();

            ViewBag.Itemlist = new SelectList(Itemlist, "ItemId", "ItemName");

            var CatgoryList = CategoryServices.GetAll(objCategory.CategoryId);

            ViewBag.categorylist = new SelectList(CatgoryList, "CategoryId", "CategoryName");

            var SubCategoryList = SubCategoryServices.GetDropDown(objSubCategory.SubCategoryId);

            ViewBag.subCategorylist = new SelectList(SubCategoryList, "SubCategoryId", "SubCategoryName");

            var SubSubCategoryList = SubSubCategoryServices.GetDropDown(objSubCategory.SubCategoryId);

            ViewBag.subSubCategoryList = new SelectList(SubSubCategoryList, "SubSubCategoryId", "SubSubCategoryName");

            var SubSubSubCategoryList = SubSubSubCategoryServices.GetDropDown(objSubCategory.SubCategoryId);

            ViewBag.subSubSubCategoryList = new SelectList(SubSubSubCategoryList, "SubSubSubCategoryId", "SubSubSubCategoryName");

            var SubSubSubSubCategoryList = SubSubSubSubCategoryServices.GetDropDown(objSubCategory.SubCategoryId);

            ViewBag.SubSubSubSubCategoryList = new SelectList(SubSubSubSubCategoryList, "SubSubSubSubCategoryId", "SubSubSubSubCategoryName");

            var BrandList = BrandServices.GetAll(i);

            ViewBag.BrandList = new SelectList(BrandList, "BrandId", "BrandName");


            var ModelList = ModelServices.GetAll(i);

            ViewBag.ModelList = new SelectList(ModelList, "ModelId", "ModelName");

            var UnitList = UnitServices.GetAll(i);

            ViewBag.UnitList = new SelectList(UnitList, "UnitId", "UnitName");
        }
        public ActionResult Update(SubCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                var subCategoryDb = this.Mapper.Map<SubCategory>(model);
                this.subCategories.Update(subCategoryDb);
                this.subCategories.SaveChanges();

                this.HttpContext.Cache.Remove("menu");
            }

            return RedirectToAction("Index");
        }