Example #1
0
        private static MessageFromCompany MaptoMessageFromCompanyDBModel(MessageFromCompanyModel messageFromCompanyModel, AccessControlSystemEntities context)
        {
            MessageFromCompany messageFromCompanyDB = new MessageFromCompany();

            messageFromCompanyDB.Value   = messageFromCompanyModel.Text;
            messageFromCompanyDB.Date    = messageFromCompanyModel.Date;
            messageFromCompanyDB.Subject = messageFromCompanyModel.Subject;
            return(messageFromCompanyDB);
        }
Example #2
0
        public static void AddNewMessage(MessageFromCompanyModel messageModel)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                MessageFromCompany messageDB = MaptoMessageFromCompanyDBModel(messageModel, context);
                context.MessageFromCompanies.Add(messageDB);
            }
            catch (Exception e)
            {
            }
        }
Example #3
0
        public MessageFromCompanyModel GetMessageFromCompanyById(int messageId, int CompanyId)
        {
            AccessControlSystemEntities context = new AccessControlSystemEntities();

            try
            {
                MessageFromCompany message = context.MessageFromCompanies.Where(x => x.CompanyId == CompanyId && x.Id == messageId).FirstOrDefault();
                return(MapToMemberMessageFromCompanyModel(message, context));
            }
            catch (Exception e)
            {
            }
            return(null);
        }
Example #4
0
        private static MessageFromCompanyModel MapToMemberMessageFromCompanyModel(MessageFromCompany messageFromCompanyDB, AccessControlSystemEntities context)
        {
            MessageFromCompanyModel messageFormCompany = new MessageFromCompanyModel();

            messageFormCompany.Id          = messageFromCompanyDB.Id;
            messageFormCompany.Text        = messageFromCompanyDB.Value;
            messageFormCompany.CompanyName = (from x in context.MessageFromCompanies
                                              where x.Id == messageFormCompany.Id
                                              from y in context.Companies
                                              where y.Id == x.CompanyId
                                              select y.Name
                                              ).FirstOrDefault();

            return(messageFormCompany);
        }