public async Task <IActionResult> Edit(Guid id, EditActionTypeViewModel model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }

            if (await ActionTypeNameExistsAsync(model.Name, id))
            {
                ModelState.AddModelError("Name", "The name already exists.");
            }

            string msg;

            if (ModelState.IsValid)
            {
                var item = new ActionType()
                {
                    Id     = model.Id,
                    Name   = model.Name,
                    Active = model.Active
                };

                try
                {
                    _cache.Remove(CacheKeys.ActionTypesSelectList);

                    _context.Update(item);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!(await ActionTypeExists(model.Id)))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                msg = string.Format("The {0} was updated.", _objectDisplayName);
                TempData.SaveAlertForSession(msg, AlertStatus.Success, "Success");

                return(RedirectToAction("Details", new { id = model.Id }));
            }

            msg = string.Format("The {0} was not updated. Please fix the errors shown below.", _objectDisplayName);
            ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");

            return(View(model));
        }
        public async Task <IActionResult> Edit(Guid id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var item = await _context.LookupActionTypes.AsNoTracking()
                       .Where(m => m.Id == id)
                       .SingleOrDefaultAsync();

            if (item == null)
            {
                return(NotFound());
            }

            var model = new EditActionTypeViewModel(item);

            return(View(model));
        }