Exemplo n.º 1
0
        public IActionResult Index()
        {
            var oneAttrVm = new OneAttributeViewModel
            {
                OneAttributes   = AttrRepo.GetAll(),
                AttributeGroups = attGroupRepo.GetAll()
            };

            return(View(oneAttrVm));
        }
Exemplo n.º 2
0
        public void Update(OneAttributeViewModel vm)
        {
            var ctxOneAttr = _ctx.OneAttributes.FirstOrDefault(a => a.Id.Equals(vm.Id));

            if (ctxOneAttr != null)
            {
                ctxOneAttr.Name        = vm.Name;
                ctxOneAttr.Description = vm.Description;
                ctxOneAttr.Type        = vm.Type;
                ctxOneAttr.UpdatedDate = DateTime.Now;
            }
            _ctx.SaveChanges();
        }
Exemplo n.º 3
0
 public void Add(OneAttributeViewModel vm)
 {
     if (vm.Id == 0)
     {
         var newAttr = new OneAttribute
         {
             Name             = vm.Name,
             Description      = vm.Description,
             Type             = vm.Type,
             AttributeGroupId = vm.AttributeGroupId,
             AddedDate        = DateTime.Now,
             UpdatedDate      = DateTime.Now,
             Published        = false,
         };
         _ctx.OneAttributes.Add(newAttr);
     }
     _ctx.SaveChanges();
 }
Exemplo n.º 4
0
 public IActionResult Update(OneAttributeViewModel vm)
 {
     AttrRepo.Update(vm);
     return(RedirectToAction(nameof(Index)));
 }
Exemplo n.º 5
0
        public IViewComponentResult Invoke(OneAttributeViewModel vm)
        {
            var oneAttrVm = new OneAttributeViewModel();

            return(View(vm));
        }
Exemplo n.º 6
0
 public IActionResult Add(OneAttributeViewModel vm)
 {
     oneAttrRepo.Add(vm);
     return(RedirectToAction(nameof(Index)));
 }