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"); }
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)); }
public IActionResult Create() { var SubCategoryViewModel = new SubCategoryViewModel() { Categories = db.Categories.ToList(), SubCategory = new SubCategory() }; return(View(SubCategoryViewModel)); }
public ActionResult CreateSubCategory(SubCategoryViewModel model) { if (ModelState.IsValid) { _subCategoryService.Create(_mapper.Map <SubCategoryDTO>(model)); return(RedirectToAction("Index", "Admin")); } return(View(model)); }
public void Update(SubCategoryViewModel model) { var subCategory = new SubCategory() { Name = model.Name, Id = model.Id, }; _subCategoryRepository.Update(subCategory); }
private CategoryPage InitiateCategoryPage() { _subCategorySelectorViewModel = new SubCategoryViewModel(); _categoryPageViewModel = new CategoryPageViewModel(_subCategorySelectorViewModel); _categoryPage = new CategoryPage(_categoryPageViewModel); _categoryPage.SubCategorySelectionChanged += _categoryPage_SubCategorySelectionChanged; return(_categoryPage); }
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")); }
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(); }
public void Create(SubCategoryViewModel SubCategoryViewModel) { var SubCategory = new SubCategory { SubCategoryName = SubCategoryViewModel.SubCategoryName, CategoryId = SubCategoryViewModel.CategoryId }; unitOfWork.SubCategoryRepository.Insert(SubCategory); unitOfWork.Save(); }
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")); }
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)); }
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)); }
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 })); }
// 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)); }
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); }
public IActionResult Index() { ViewBag.EntityType = "SubCategory"; var subCatVm = new SubCategoryViewModel { SubCategories = subCatrepo.GetAll(), Categories = catRepo.GetAll(), AttributeGroups = attrGroupRepo.GetAll() }; return(View(subCatVm)); }
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")); } }
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")); } }
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)); }
// 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)); }
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")); } }
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"); }