public AttributeGroupViewModel GetAttributeGroupById(int attributeGroupId)
        {
            AttributeGroup          attributeGroup          = _ctx.AttributeGroups.FirstOrDefault(f => f.Id == attributeGroupId);
            AttributeGroupViewModel attributeGroupViewModel = AttributeGroupFactory.AttributeGroupToViewModel(attributeGroup);

            return(attributeGroupViewModel);
        }
Example #2
0
        public ActionResult Attributes(AttributeGroupViewModel postAttribute)
        {
            if (ModelState.IsValid)
            {
                var form = postAttribute.Form;
                if (form.NewGroup != null)
                {
                    var group = new AttributeGroup()
                    {
                        AttributeGroupName = form.NewGroup
                    };
                    _context.AttributeGroups.Add(group);
                    _context.SaveChanges();
                }
                else if (form.SelectGroup != null && form.AttributeName != null)
                {
                    var attribute = new Models.Attribute()
                    {
                        AttributeGroupId = form.SelectGroup, Name = form.AttributeName, ValueType = form.ValueType
                    };
                    _context.Attributes.Add(attribute);
                    _context.SaveChanges();
                }
            }

            return(RedirectToAction(nameof(AttributesController.Attributes), "Attributes"));
        }
Example #3
0
        public IActionResult Update(AttributeGroupViewModel vm)
        {
            attrGroupRepo.Update(vm);
            var url = Url.Action("Index", "AttributeGroup");

            return(Json(url));
        }
Example #4
0
        public ActionResult Attributes()
        {
            var viewModel = new AttributeGroupViewModel();

            viewModel.AttributeGroup = _context.AttributeGroups.Include(x => x.Attribute).ToList();

            return(View(viewModel));
        }
        public async Task Add(AttributeGroupViewModel attributeGroup)
        {
            var model = _mapper.Map <AttributeGroup>(attributeGroup);

            _attributeGroupRepository.Add(model);

            await _unitOfWork.CompleteAsync();
        }
Example #6
0
        // GET: AttributeGroup
        public ActionResult Index()
        {
            var attributeGroupList = new AttributeGroupViewModel();

            {
                attributeGroupList.AttributeGroup = db.AttributeGroups.ToList();
            }

            return(View(attributeGroupList));
        }
Example #7
0
        public void Publish(AttributeGroupViewModel vm)
        {
            var ctxAttributeGroupViewModel = _ctx.AttributeGroups.FirstOrDefault(ag => ag.Id.Equals(vm.Id));

            if (ctxAttributeGroupViewModel != null)
            {
                ctxAttributeGroupViewModel.Id        = vm.Id;
                ctxAttributeGroupViewModel.Published = vm.Published;
            }
            _ctx.SaveChanges();
        }
Example #8
0
        public IActionResult Index()
        {
            var attrGroupVm = new AttributeGroupViewModel
            {
                AttributeGroups = attrGroupRepo.GetAll(),
                SubCategories   = subCatRepo.GetAll(),
                OneAttributes   = oneAttrRepo.GetAll()
            };

            return(View(attrGroupVm));
        }
Example #9
0
        public void Update(AttributeGroupViewModel vm)
        {
            var ctxAttrGroup = _ctx.AttributeGroups.FirstOrDefault(attrg => attrg.Id.Equals(vm.Id));

            if (ctxAttrGroup != null)
            {
                ctxAttrGroup.Name        = vm.Name;
                ctxAttrGroup.Description = vm.Description;
                ctxAttrGroup.UpdatedDate = DateTime.Now;
            }
            _ctx.SaveChanges();
        }
Example #10
0
        public static AttributeGroupViewModel AttributeGroupToViewModel(AttributeGroup attributeGroup)
        {
            var attributeGroupViewModel = new AttributeGroupViewModel()
            {
                AttributeGroupId   = attributeGroup.Id,
                AttributeGroupName = attributeGroup.Name,
                CreationDate       = attributeGroup.CreationDate,
                LastModifiedDate   = attributeGroup.LastModifiedDate
            };

            return(attributeGroupViewModel);
        }
Example #11
0
 public void Add(AttributeGroupViewModel vm)
 {
     if (vm.Id == 0)
     {
         var newAttrGroup = new AttributeGroup
         {
             Name          = vm.Name,
             Description   = vm.Description,
             OneAttributes = null,
             AddedDate     = DateTime.Now,
             UpdatedDate   = DateTime.Now,
             Published     = false,
         };
         _ctx.AttributeGroups.Add(newAttrGroup);
     }
     _ctx.SaveChanges();
 }
Example #12
0
        public async Task <IActionResult> Add(AttributeGroupViewModel model)
        {
            await _attributeGroupService.Add(model);

            return(RedirectToAction("Index"));
        }
Example #13
0
 public IActionResult Add(AttributeGroupViewModel vm)
 {
     attrGroupRepo.Add(vm);
     return(RedirectToAction(nameof(Index)));
 }
Example #14
0
        public IViewComponentResult Invoke(AttributeGroupViewModel vm)
        {
            var attrGroupVm = new AttributeGroupViewModel();

            return(View(vm));
        }