public IActionResult Save(UrgencyViewModel item)
 {
     if (ModelState.IsValid)
     {
         _service.AddUpdateUrgency(item);
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Edit"));
 }
示例#2
0
        public UrgencyViewModel GetUrgencyItem(int id)
        {
            var result = _dbContext.Urgencies.Find(id);
            var item   = new UrgencyViewModel()
            {
                Id           = result.Id,
                UrgencyLevel = result.UrgencyLevel,
                Description  = result.Description,
                IsActive     = result.IsActive
            };

            return(item);
        }
示例#3
0
        public IActionResult Index()
        {
            TempData["Active"] = "Urgency";
            List <Urgency> Urgencyler = _UrgencyService.GetAll();

            List <UrgencyViewModel> model = new List <UrgencyViewModel>();

            foreach (var item in Urgencyler)
            {
                UrgencyViewModel models = new UrgencyViewModel();
                models.Id          = item.Id;
                models.Description = item.Description;
                model.Add(models);
            }

            return(View(model));
        }
示例#4
0
        public void AddUpdateUrgency(UrgencyViewModel item)
        {
            var entity = _dbContext.Urgencies.Find(item.Id) ?? new Urgency();

            entity.UrgencyLevel = item.UrgencyLevel;
            entity.Description  = item.Description;
            entity.IsActive     = item.IsActive;

            if (entity.Id != 0)
            {
                _dbContext.Urgencies.Update(entity);
            }
            else
            {
                _dbContext.Urgencies.Add(entity);
            }

            _dbContext.SaveChanges();
        }