public IActionResult Save(UrgencyViewModel item) { if (ModelState.IsValid) { _service.AddUpdateUrgency(item); return(RedirectToAction("Index")); } return(RedirectToAction("Edit")); }
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); }
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)); }
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(); }