示例#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 ActionResult Edit(int id, NotificationModel model)
        {
            try
            {
                var notification = TheModelFactory.Parse(model);

                if (notification == null)
                {
                    return RedirectToAction("Index", "Error", new { errorMsg = "Invalid notification data" });
                }

                if (TheRepository.EditNotification(id, TheIdentityService.CurrentUser, notification))
                {
                    return RedirectToAction("Index");
                }

                return RedirectToAction("Index", "Error", new { errorMsg = "Error updating contact group" });
            }
            catch (Exception ex)
            {
                return RedirectToAction("Index", "Error", new { errorMsg = ex.Message });
            }
        }
示例#3
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;
        }
        public ActionResult NewNotification(NotificationModel model)
        {
            try
            {
                // TODO: Add insert logic here
                var notification = TheModelFactory.Parse(model);

                if (notification == null)
                {
                    return RedirectToAction("Index", "Error", new { errorMsg = "Invalid Create Notification Data." });
                }

                if (TheRepository.AddNotification(TheIdentityService.CurrentUser, notification))
                {
                    return RedirectToAction("Index");
                }

                return RedirectToAction("Index", "Error", new { errorMsg = "Error adding new notification" });
            }
            catch(Exception ex)
            {
                return RedirectToAction("Index", "Error", new { errorMsg = ex.Message });
            }
        }