Example #1
0
    protected void btMessageOK_Click(object sender, EventArgs e)
    {
        if (String.IsNullOrWhiteSpace(tbxMessage.Text))
        {
            lbMessageError.Text = "შეავსეთ მესიჯის ტექსტი!";
            mpeMessage.Show();
            upnlMessage.Update();
            return;
        }

        if (String.IsNullOrWhiteSpace(tbxSubject.Text))
        {
            lbMessageError.Text = "შეავსეთ მესიჯის სათაური!";
            mpeMessage.Show();
            upnlMessage.Update();
            return;
        }

        if (ObjectId == null)
        {
            return;
        }


        Guid messageId;

        Guid.TryParse(ddlSubjects.Value.ToString(), out messageId);

        var message = (from n in DataContext.UM_Messages
                       where n.DateDeleted == null &&
                       n.ID == messageId
                       select n).FirstOrDefault();

        if (message == null || messageId == Guid.Empty)
        {
            message             = new UM_Message();
            message.ID          = Guid.NewGuid();
            message.ObjectID    = ObjectId.Value;
            message.DateCreated = DateTime.Now;

            DataContext.UM_Messages.InsertOnSubmit(message);
        }


        message.Text        = tbxMessage.Text;
        message.Subject     = tbxSubject.Text;
        message.Type        = (int)Enum.Parse(typeof(MessageTypeEnum), ddlMessageType.SelectedItem.Value.ToString());
        message.DateChanged = DateTime.Now;

        DataContext.SubmitChanges();
    }
Example #2
0
        public static UM_Message ToEntity(this MessageContract contract)
        {
            if (contract == null)
            {
                return(null);
            }

            var entity = new UM_Message();

            entity.ID          = contract.ID;
            entity.Text        = contract.Text;
            entity.ObjectID    = contract.ObjectID;
            entity.Type        = contract.Type;
            entity.DateChanged = contract.DateChanged;
            entity.DateCreated = contract.DateCreated;
            entity.DateDeleted = contract.DateDeleted;

            return(entity);
        }
Example #3
0
        public static MessageContract ToContract(this UM_Message entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var contract = new MessageContract();

            contract.ID          = entity.ID;
            contract.Text        = entity.Text;
            contract.ObjectID    = entity.ObjectID;
            contract.Type        = entity.Type;
            contract.DateCreated = entity.DateCreated;
            contract.DateChanged = entity.DateChanged;
            contract.DateDeleted = entity.DateDeleted;

            return(contract);
        }