Esempio n. 1
0
        public IActionResult Index()
        {
            var result = _EmployeeCategory.EmployeeCategories()
                         .Select(a => new EmployeeCategoryViewModel
            {
                Id          = a.Id,
                Description = a.Description
            }).ToList();
            var model = new EmployeeCategoryIndexViewModel
            {
                EmployeeCategories = result
            };

            return(View(model));
        }
Esempio n. 2
0
        public IActionResult Save(EmployeeCategoryIndexViewModel model)
        {
            var UserId = HttpContext.Session.GetString("UserId");

            if (ModelState.IsValid)
            {
                var item = new EmployeeCategory
                {
                    Id          = model.Id,
                    Description = model.Description
                };
                _EmployeeCategory.Save(item, UserId);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index", model));
            }
        }