Ejemplo n.º 1
0
        /// <summary>
        /// Creates a business object using a model as a source
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static Sedogo.BusinessObjects.Message CreateMessageBO(MessageModel model)
        {
            var msg = new Sedogo.BusinessObjects.Message(model.CreatedByFullName);

            if(!string.IsNullOrEmpty(model.message)) msg.messageText = model.message;
            if(model.Event.HasValue) msg.eventID = model.Event.Value;
            msg.userID = model.user;
            msg.postedByUserID = model.author;
            msg.messageRead = model.read;

            return msg;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to create a message model using input parameters. If the attempt is unsuccessful, the output error parameter
        /// contains the error message
        /// </summary>
        /// <param name="message"></param>
        /// <param name="Event"></param>
        /// <param name="user"></param>
        /// <param name="author"></param>
        /// <param name="read"></param>
        /// <param name="CreatedByFullName"></param>
        /// <param name="LastUpdatedByFullName"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public static MessageModel CreateMessageModel(string message, int? Event, int? user, int? author, bool? read,
            string CreatedByFullName, string LastUpdatedByFullName, out string error)
        {
            error = null;
            if (!user.HasValue)
                error = "user-attribute-required";
            else if (!author.HasValue)
                error = "author-attribute-required";
            else if (!read.HasValue)
                error = "read-attribute-required";

            if (!string.IsNullOrEmpty(error))
                return null;

            MessageModel model = new MessageModel {
                created = DateTime.Now,
                updated = DateTime.Now,
                message = message,
                Event =Event,
                user = user.Value,
                author = author.Value,
                read = read.Value,
                CreatedByFullName = CreatedByFullName,
                LastUpdatedByFullName = LastUpdatedByFullName
            };
            return model;
        }