示例#1
0
        public Notification Parse(NotificationModel model)
        {
            try
            {
                var notificationEntity = new Notification();
                notificationEntity.Name = model.NotificationName;
                notificationEntity.PhoneFormat = model.HasPhoneCallMsg;
                notificationEntity.TextFormat = model.HasTextMsg;
                notificationEntity.EmailFormat = model.HasEmailMsg;
                notificationEntity.FaxFormat = model.HasFaxMsg;
                //notificationEntity.NotificationType = model.NotificationType;
                notificationEntity.PhoneMessageText = model.PhoneMessageMsg;
                //notificationEntity.PhoneMessageType = model.PhoneMessageType;
                notificationEntity.EmailSubject = model.EmailSubject;
                notificationEntity.EmailFrom = model.EmailFrom;
                notificationEntity.EmailMessage = model.EmailMessage;
                notificationEntity.FaxSendCoverPage = model.FaxSendCoverPage;
                notificationEntity.FaxFrom = model.FaxFrom;
                notificationEntity.FromFaxPhoneNumber = model.FaxFromNumber;
                notificationEntity.FromFaxComments = model.FaxComments;
                notificationEntity.TextMessage = model.TextMessage;

                return notificationEntity;
            }
            catch (Exception)
            {
                return null;
            }
        }
 public NotificationModal Create(Notification notification)
 {
     return new NotificationModal()
     {
         URL = _urlHelper.Link("Notifications", new { notificationid = notification.Id }),
         Name = notification.Name,
         PhoneMessageText = notification.PhoneMessageText,
         TextMessage = notification.TextMessage,
         DateAdded =  notification.DateAdded
     };
 }
        public Notification Parse(NotificationModal model)
        {
            try
            {
                var notification = new Notification
                {
                    Name = model.Name,
                    PhoneMessageText = model.PhoneMessageText,
                    TextMessage = model.TextMessage,
                    DateAdded = DateTime.Now
                };

                //Below code is an example of how to get ID for url's pass in to the model
                //var uri = new Uri(model.URL);
                //var notificationId = int.Parse(uri.Segments.Last());

                return notification;
            }
            catch (Exception)
            {
                return null;
            }
        }
示例#4
0
        public NotificationModel Create(Notification notification)
        {
            var result = new NotificationModel
            {
                NotificationName = notification.Name,
                HasPhoneCallMsg = notification.PhoneFormat != null ? Convert.ToBoolean(notification.PhoneFormat) : false,
                HasTextMsg = notification.TextFormat != null ? Convert.ToBoolean(notification.TextFormat) : false,
                HasEmailMsg = notification.EmailFormat != null ? Convert.ToBoolean(notification.EmailFormat) : false,
                HasFaxMsg = notification.FaxFormat != null ? Convert.ToBoolean(notification.FaxFormat) : false,
                //NotificationType = ModelEnums.CreateModelEnums.NotificationTypeDic[notification.NotificationType],
                PhoneMessageMsg = notification.PhoneMessageText,
                //PhoneMessageType = ModelEnums.CreateModelEnums.PhoneMessageTypeDic[notification.PhoneMessageType],
                EmailSubject = notification.EmailSubject,
                EmailFrom = notification.EmailFrom,
                EmailMessage = notification.EmailMessage,
                FaxSendCoverPage =
                    notification.FaxSendCoverPage != null ? Convert.ToBoolean(notification.FaxSendCoverPage) : false,
                FaxFrom = notification.FaxFrom,
                FaxFromNumber = notification.FromFaxPhoneNumber,
                FaxComments = notification.FromFaxComments,
                TextMessage = notification.TextMessage,
                DateAdded = notification.DateAdded

            };

            return result;
        }
示例#5
0
        public bool AddNotification(string username, Notification entity)
        {
            try
            {
                var user = _contex.Users.SingleOrDefault(c => c.Id == entity.CreatedByUserId);
                entity.CreatedBy = user;
                entity.DateAdded = DateTime.Now;
                entity.LastUsed = DateTime.Now;

                _contex.SaveChanges();

                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
示例#6
0
        public bool EditNotification(int notificationId, string username, Notification entity)
        {
            try
            {
                //Get Notification Id
                var notification = _contex.Notifications.SingleOrDefault(c => c.Id == notificationId);

                if (notification == null)
                {
                    return false;
                }

                //Validate that user is part of organization that the notification belongs to
                if(notification.CreatedBy.Organization.Users.All(c => c.UserID != username))
                {
                    return false;
                }

                notification.Name = entity.Name;
                notification.PhoneFormat = entity.PhoneFormat;
                notification.TextFormat = entity.TextFormat;
                notification.EmailFormat = entity.EmailFormat;
                notification.FaxFormat = entity.FaxFormat;
                notification.NotificationType = entity.NotificationType;
                notification.PhoneMessageText = entity.PhoneMessageText;
                notification.PhoneMessageType = entity.PhoneMessageType;
                notification.EmailSubject = entity.EmailSubject;
                notification.EmailFrom = entity.EmailFrom;
                notification.EmailMessage = entity.EmailMessage;
                notification.FaxSendCoverPage = entity.FaxSendCoverPage;
                notification.FaxFrom = entity.FaxFrom;
                notification.FromFaxPhoneNumber = entity.FromFaxPhoneNumber;
                notification.FromFaxComments = entity.FromFaxComments;
                notification.TextMessage = entity.TextMessage;
                notification.LastUsed = DateTime.Now;

                if (SaveAll())
                {
                    return true;
                }

                return false;

            }
            catch (Exception)
            {
                return false;

            }
        }