Exemplo n.º 1
0
 public ActionResult CreateOrUpdateAction(string id, AppActionViewModel model)
 {
     using (var context = new AppSecurityContext())
     {
         try
         {
             var action     = mapper.Map <AppAction>(model);
             var repository = new ActionRepository(context);
             if (id != null)
             {
                 repository.Update(action);
             }
             else
             {
                 repository.Insert(action);
             }
             context.SaveChanges();
             return(RedirectToAction("Actions"));
         }
         catch (Exception ex)
         {
             ViewBag.Error = ex.Message;
             return(View(model));
         }
     }
 }
Exemplo n.º 2
0
        public IActionResult Put(int id, Models.Action action)
        {
            if (id != action.Id)
            {
                return(BadRequest());
            }

            _actionRepository.Update(action);
            return(NoContent());
        }
Exemplo n.º 3
0
        public static void SaveActions(Action action)
        {
            if (action.Id == null)
            {
                _actionRepository.Insert(action);
            }
            else
            {
                _actionRepository.Update(action);
            }

            _actionRepository.SaveChangesAsync();
        }
Exemplo n.º 4
0
    private Neos.Data.Action SaveAction()
    {
        if (SessionManager.CurrentUser == null)
        {
            Common.RedirectToLoginPage(this);
            return null;
        }

        ActionRepository repo = new ActionRepository();
        Neos.Data.Action saveItem = GetAction();
        if (string.IsNullOrEmpty(Request.QueryString["ActionID"]))
        {
            //Insert new record
            repo.Insert(saveItem);
        }
        else
        {
            //Update the record.
            saveItem.ActionID = int.Parse(Request.QueryString["ActionID"]);
            repo.Update(saveItem);
        }
        if (chkExportToOutlook.Checked)
        {
            string message = Common.ExportActionToAppoinment(saveItem);
            string script1 = "<script type=\"text/javascript\">";
            script1 += " alert(\"" + message + "\")";
            script1 += " </script>";
            if (!this.ClientScript.IsClientScriptBlockRegistered("exportAction"))
                this.ClientScript.RegisterStartupScript(this.GetType(), "exportAction", script1);
        }

        return saveItem;
    }