public AttributeGroupViewModel GetAttributeGroupById(int attributeGroupId) { AttributeGroup attributeGroup = _ctx.AttributeGroups.FirstOrDefault(f => f.Id == attributeGroupId); AttributeGroupViewModel attributeGroupViewModel = AttributeGroupFactory.AttributeGroupToViewModel(attributeGroup); return(attributeGroupViewModel); }
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")); }
public IActionResult Update(AttributeGroupViewModel vm) { attrGroupRepo.Update(vm); var url = Url.Action("Index", "AttributeGroup"); return(Json(url)); }
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(); }
// GET: AttributeGroup public ActionResult Index() { var attributeGroupList = new AttributeGroupViewModel(); { attributeGroupList.AttributeGroup = db.AttributeGroups.ToList(); } return(View(attributeGroupList)); }
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(); }
public IActionResult Index() { var attrGroupVm = new AttributeGroupViewModel { AttributeGroups = attrGroupRepo.GetAll(), SubCategories = subCatRepo.GetAll(), OneAttributes = oneAttrRepo.GetAll() }; return(View(attrGroupVm)); }
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(); }
public static AttributeGroupViewModel AttributeGroupToViewModel(AttributeGroup attributeGroup) { var attributeGroupViewModel = new AttributeGroupViewModel() { AttributeGroupId = attributeGroup.Id, AttributeGroupName = attributeGroup.Name, CreationDate = attributeGroup.CreationDate, LastModifiedDate = attributeGroup.LastModifiedDate }; return(attributeGroupViewModel); }
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(); }
public async Task <IActionResult> Add(AttributeGroupViewModel model) { await _attributeGroupService.Add(model); return(RedirectToAction("Index")); }
public IActionResult Add(AttributeGroupViewModel vm) { attrGroupRepo.Add(vm); return(RedirectToAction(nameof(Index))); }
public IViewComponentResult Invoke(AttributeGroupViewModel vm) { var attrGroupVm = new AttributeGroupViewModel(); return(View(vm)); }