public ActionResult TargetEdit(int targetId)
 {
     var model = new TargetEditModel
     {
         Target = _reader.GetTargetById(targetId)
     };
     return View("TargetEdit", model);
 }
        public ActionResult TargetEdit(TargetEditModel model, string button)
        {
            var userId = UserDetails.CurrentUser().Id;
            var target = model.Target;

            if (button.ToLower().StartsWith("delete"))
            {
                if (UserDetails.CurrentUser().IsAdministrator)
                {
                    // Audit state in database before deletion
                    var targetFromDatabase = _reader.GetTargetById(target.Id);
                    _writer.DeleteTargetConfig(target);
                    _writer.NewTargetConfigAudit(new TargetConfigAudit(targetFromDatabase, userId, "Deleted"));
                }
            }
            else
            {
                _writer.UpdateTargetConfig(model.Target);
                _writer.NewTargetConfigAudit(new TargetConfigAudit(model.Target, userId, "Updated"));
            }
            return Redirect(SiteUrls.TargetIndex);
        }
 public ActionResult TargetNew(TargetEditModel model)
 {
     _writer.NewTargetConfig(model.Target);
     _writer.NewTargetConfigAudit(new TargetConfigAudit(model.Target, UserDetails.CurrentUser().Id, "New"));
     return Redirect(SiteUrls.TargetIndex);
 }
 public ActionResult TargetNew()
 {
     var model = new TargetEditModel
     {
         Target = new TargetConfig()
     };
     return View("TargetEdit", model);
 }