Exemple #1
0
 public frmPostWallMessageAction(AppConfigAction action, PostWallMessage postWallMessage = null)
 {
     InitializeComponent();
     this.Action = action;
     this.Result = postWallMessage;
     this.Load  += FrmPostWallMessageAction_Load;
 }
Exemple #2
0
 private void BtnOk_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(TbMessage.Text))
     {
         Until.ShowErrorBox("Message must be not null or empty!");
     }
     Result = new PostWallMessage()
     {
         Message = TbMessage.Text
     };
     DialogResult = DialogResult.OK;
 }
        public bool PostWallMessageAction(PostWallMessage postWallMessage, ActionType type = ActionType.Add)
        {
            if (IsOpenSuccess)
            {
                try
                {
                    var message = Data.PostWallContentsTemplate.Where(m => m.Id == postWallMessage.Id).FirstOrDefault();
                    switch (type)
                    {
                    case ActionType.Add:
                        if (message == null)
                        {
                            Data.PostWallContentsTemplate.Add(message);
                            Save();
                            return(true);
                        }
                        return(false);

                    case ActionType.Edit:
                        if (message != null)
                        {
                            Data.PostWallContentsTemplate.Remove(message);
                            Data.PostWallContentsTemplate.Add(postWallMessage);
                            Save();
                            return(true);
                        }
                        return(false);

                    case ActionType.Remove:
                        if (message != null)
                        {
                            Data.PostWallContentsTemplate.Remove(message);
                            Save();
                        }
                        return(true);

                    default:
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    ex.StackTrace.WriteLog();
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }