Exemplo n.º 1
0
 private void ValidateNotificationModel(NotificationDomain notification)
 {
     ValidationHelper.NotNull(notification, NotificationMessages.NotificationNotProvided);
     ValidationHelper.NotNull(notification.ExternalId, NotificationMessages.NotificationExternalIdNotProvided);
     ValidationHelper.NotNull(notification.NotificationStatusId, NotificationMessages.NotificationStatusIdNotProvided);
     ValidationHelper.NotNull(notification.NotificationTypeId, NotificationMessages.NotificationTypeIdNotProvided);
     ValidationHelper.GreaterThanZero(notification.NotificationStatusId, NotificationMessages.EmailNotificationStatusIdInvalid);
     ValidationHelper.GreaterThanZero(notification.NotificationTypeId, NotificationMessages.NotificationTypeIdInvalid);
     ValidationHelper.NotNull(_notificationStatusRepository.GetById(notification.NotificationStatusId), NotificationMessages.NotificationStatusIdDoesNotExist);
     ValidationHelper.NotNull(_notificationTypeRepository.GetById(notification.NotificationTypeId), NotificationMessages.NotificationTypeWithIdDoesNotExist);
 }
Exemplo n.º 2
0
 public void Populate(NotificationEntity source, Notification destination)
 {
     destination.AttemptCount       = source.AttemptCount;
     destination.Source             = source.ClientLabel;
     destination.DateCreated        = source.DateCreated.GetValueOrDefault();
     destination.Notes              = source.Notes;
     destination.NotificationDate   = source.NotificationDate;
     destination.NotificationType   = _notificationTypeRepository.GetById(source.NotificationTypeId);
     destination.NotificationMedium = _notificationMediumRepository.GetById(source.NotificationMediumId);
     destination.Priority           = source.Priority;
     destination.RequestedBy        = source.RequestedByOrgRoleUserId.HasValue ? source.RequestedByOrgRoleUserId.Value : 0;
     destination.ServicedDate       = source.ServicedDate;
     destination.ServiceStatus      = (NotificationServiceStatus)(source.ServiceStatus ?? (byte)NotificationServiceStatus.Unserviced);
     destination.UserId             = source.UserId;
 }
Exemplo n.º 3
0
        public string LoadTemplate(string emailTemplateAlias, long notificationTypeId, string body = null)
        {
            var content = string.Empty;

            var notificationtype = _notificationTypeRepository.GetById(notificationTypeId);

            // No binding exisits between Template and Notification Type. As discussed, using emailTemplateAlias as notification Type
            switch (notificationtype.NotificationTypeAlias)
            {
            case NotificationTypeAlias.ScreeningReminderMail:
            case NotificationTypeAlias.AppointmentConfirmationWithEventDetails:
                var appointmentConfModel = _emailNotificationModelsFactory.GetDummyDataAppointmentConfirmationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, appointmentConfModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.AppointmentBookedInTwentyFourHours:
                var appointmentbookedModel = _emailNotificationModelsFactory.GetDummyAppointmentBookedInTwentyFourHoursModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, appointmentbookedModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.LoginIssuesSendUsername:
            case NotificationTypeAlias.EmployeeWelcomeEmailWithUsername:
            case NotificationTypeAlias.CustomerWelcomeEmailWithUsername:
                var welcomWithUNameModel = _emailNotificationModelsFactory.GetDummyDataWelcomeWithUserNameNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, welcomWithUNameModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.LoginIssuesSendResetMail:
            case NotificationTypeAlias.EmployeeWelcomeEmailWithResetMail:
            case NotificationTypeAlias.CustomerWelcomeEmailWithResetMail:
                var welcomeWithPasswordModel = _emailNotificationModelsFactory.GetDummyDataWelcomeWithPasswordNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, welcomeWithPasswordModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ResetMail:
                var resetPasswordModel = _emailNotificationModelsFactory.GetDummyDataResetModificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, resetPasswordModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.GiftCertificateAcknowledgmentEmail:
            case NotificationTypeAlias.GiftCertificateClaimCodeEmail:
                var giftCertificateModel = _emailNotificationModelsFactory.GetDummyDataGiftCertificateNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, giftCertificateModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CriticalCustomer:
                var criticalCustomer = _emailNotificationModelsFactory.GetDummyCriticalCustomerNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, criticalCustomer);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.PriorityInQueueCustomer:
                var priorityInQueueCustomer = _emailNotificationModelsFactory.GetDummyPriorityInQueueNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, priorityInQueueCustomer);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.AmountRefundNotification:
                var amountRefund = _emailNotificationModelsFactory.GetDummyAmountRefundNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, amountRefund);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.EvaluationReminder:
                var evalReminder = _emailNotificationModelsFactory.GetDummyEvaluationReminderNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, evalReminder);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ResultsReady:
                var resultReady = _emailNotificationModelsFactory.GetDummyResultReadyModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, resultReady);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ThirtyDaysFromAnnualAnniversaryEmailer:
            case NotificationTypeAlias.OneWeekAfter30DayReminder:
            case NotificationTypeAlias.TwoWeekAfter30DayReminder:
            case NotificationTypeAlias.OnOneYearAnniversaryDate:
                var annualReminder = _emailNotificationModelsFactory.GetDummyAnnualReminderNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, annualReminder);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.SurveyEmailNotification:
                var surveyNotification = _emailNotificationModelsFactory.GetDummySurveyNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, surveyNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.OneDayAfterProspectCreationFollowup:
            case NotificationTypeAlias.OneWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.TwoWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.ThreeWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.FourWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.FiveWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.SixWeekAfterProspectCreationFollowup:
            case NotificationTypeAlias.SevenWeekAfterProspectCreationFollowup:
                var prospectNotification = _emailNotificationModelsFactory.GetDummyProspectCustomerFollowupNotificationViewModel();
                content = this.GetEmailMessagewithdummyData(emailTemplateAlias, body, prospectNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.EventFillingNotification:
                var emailFilling = _emailNotificationModelsFactory.GetDummyEventFillingNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, emailFilling);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.PurchaseShippingNotification:
                var purchaseShipping = _emailNotificationModelsFactory.GetDummyPurchaseShippingNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, purchaseShipping);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.UrgentCustomer:
                var urgentCustomer = _emailNotificationModelsFactory.GetDummyUrgentCustomerNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, urgentCustomer);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.TestUpsellNotification:
                var testUpsellNotification = _emailNotificationModelsFactory.GetDummyTestUpsellNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, testUpsellNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.EventResultReadyNotification:
                var eventResultReadyNotification = _emailNotificationModelsFactory.GetDummyEventResultReadyNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, eventResultReadyNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.KynFirstNotification:
            case NotificationTypeAlias.KynSecondNotification:
                var kynNotification = _emailNotificationModelsFactory.GetDummyKynNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, kynNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case EmailTemplateAlias.AppointmentReminder:
                var appointmentReminder = _phoneNotificationModelsFactory.GetDummyScreeningReminderSmsNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, appointmentReminder);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.AppointmentConfirmation:
                var appointmentConfirmation = _phoneNotificationModelsFactory.GetDummyScreeningReminderSmsNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, appointmentConfirmation);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.PhysicianPartnerSurveyEmailNotification:
                var ppSurveyNotification = _emailNotificationModelsFactory.GetDummySurveyNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, ppSurveyNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.PhysicianPartnersCustomerResultReady:
                var ppCustomerResultReady = _emailNotificationModelsFactory.GetDummyPpCustomerResultNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, ppCustomerResultReady);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.EventFullNotification:
                var emailEventFull = _emailNotificationModelsFactory.GetDummyEventFillingNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, emailEventFull);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.LoginOtpEmailNotification:
                var emailNotif = _emailNotificationModelsFactory.GetDummyLoginOtpEmailNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, emailNotif);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.LoginOtpSmsNotification:
                var smsNotif = _phoneNotificationModelsFactory.GetDummyUserLoginOtpModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, smsNotif);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CustomerTagUpdated:
                var customerTagChangeNotif = _emailNotificationModelsFactory.GetDummyCustomerTagChangeNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, customerTagChangeNotif);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.EventLocked:
                var eventLockedNotification = _emailNotificationModelsFactory.GetDummyEventLockedNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, eventLockedNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.NoShowCustomer:
                var noshowCustomerNotification = _emailNotificationModelsFactory.GetDummyNoShowCustomerNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, noshowCustomerNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CorporateUploadNotification:
                var corporateUploadNotification = _emailNotificationModelsFactory.GetDummyCorporateUploadNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, corporateUploadNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.DirectMailActivityNotification:
                var directEmailNotificationViewModel = _emailNotificationModelsFactory.GetDummyDirectMailActivityNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, directEmailNotificationViewModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.IneligibleCustomerAppointmentNotification:
                var directIneligibleCustomerAppointmentNotificationViewModel = _emailNotificationModelsFactory.GetDummyIneligibleCustomerAppointmentNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, directIneligibleCustomerAppointmentNotificationViewModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ExportToCsvNotification:
                var directcustomerExportNotificationtNotificationViewModel = _emailNotificationModelsFactory.GetDummyCustomerExportableReportsNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, directcustomerExportNotificationtNotificationViewModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CancelRescheduleAppointmentNotification:
                var cancellationRescheduleNotificationViewModel = _emailNotificationModelsFactory.GetDummyCancelRescheduleAppointmentNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, cancellationRescheduleNotificationViewModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.PatientLeftNotification:
                var patientLeftNotificationViewModel = _emailNotificationModelsFactory.GetDummyPatientLeftNotificationModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, patientLeftNotificationViewModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CustomEventSmsNotification:
                var customEventSmsNotificationModel = _phoneNotificationModelsFactory.GetDummyCustomEventSmsNotificatonModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, customEventSmsNotificationModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.RecordSendBackForCorrection:
                var recordSendBackForCorrectionNotificationModel = _emailNotificationModelsFactory.GetDummyRecordSendBackForCorrectionNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, recordSendBackForCorrectionNotificationModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.HourlyNotificationAppointmentBookedReport:
                var hourlyNoitificationAppointment = _emailNotificationModelsFactory.GetDummyHourlyAppointmentBookedReportNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, hourlyNoitificationAppointment);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.HourlyNotificationOutreachCallReport:
                var hourlyOutreachReport = _emailNotificationModelsFactory.GetDummyHourlyOutreachNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, hourlyOutreachReport);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.MergeCustomer:
                var mergeCustomerModel = _emailNotificationModelsFactory.GetDummyMergeCustomerViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, mergeCustomerModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.WrongSmsReponse:
                var wrongSmsReponse = _phoneNotificationModelsFactory.GetDummyWrongSmsResponseNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, wrongSmsReponse);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.WellcomeSmsMessage:
                var wellcomeSmsNotification = _phoneNotificationModelsFactory.GetDummyWellcomeSmsNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, wellcomeSmsNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.FileNotPosted:
                var fileNotPostedModel = _emailNotificationModelsFactory.GetDummyFileNotPostedViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, fileNotPostedModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.TestNotPerformedSupplyIssue:
                var testNotPerformedSupplyIssue = _emailNotificationModelsFactory.GetDummyTestNotPerformedEmailNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, testNotPerformedSupplyIssue);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.TestNotPerformedEquipmentMalfunction:
                var testNotPerformedEquipmentMalfunction = _emailNotificationModelsFactory.GetDummyTestNotPerformedEmailNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, testNotPerformedEquipmentMalfunction);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ReTestNotification:
                var reTestNotification = _emailNotificationModelsFactory.GetDummyReTestNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, reTestNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.NonTargetedMemberRegistrationNotification:
                var nonTargetedMemberRegistrationNotification = _emailNotificationModelsFactory.GetDummyNonTargetedMemberRegistrationNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, nonTargetedMemberRegistrationNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.MammoPatientRegistrationOnNonMammoEventNotification:
                var mammoPatientRegistrationOnNonMammoEventNotification = _emailNotificationModelsFactory.GetDummyMammoPatientRegestrationOnNonMammoEventViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, mammoPatientRegistrationOnNonMammoEventNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.SingleTestOverrideNotification:
                var singleTestOverrideNotification = _emailNotificationModelsFactory.GetDummySingleTestOverrideNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, singleTestOverrideNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.NPfordiagnosingwithlinkNotification:
                var NPfordiagnosingwithlinkNotification = _emailNotificationModelsFactory.GetDummyNPfordiagnosingwithlinkNotificationViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, NPfordiagnosingwithlinkNotification);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.CoverLetterTemplate:
                var coverLetterTemplate = _emailNotificationModelsFactory.GetDummyCoverLetterTemplateViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, coverLetterTemplate);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.ListWithoutCustomTags:
                var listWithoutCustomTags = _emailNotificationModelsFactory.GetDummyListWithoutCustomTagsViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, listWithoutCustomTags);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;

            case NotificationTypeAlias.AbsenceByMember:
                var AbsenceByMemberModel = _emailNotificationModelsFactory.GetDummyAbsenceByMemberPostedViewModel();
                content = GetEmailMessagewithdummyData(emailTemplateAlias, body, AbsenceByMemberModel);
                if (!string.IsNullOrEmpty(content))
                {
                    return(content);
                }
                break;
            }

            return(content);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Get notification type by id
 /// </summary>
 /// <param name="notificationTypeId"></param>
 /// <returns></returns>
 public NotificationTypeDomain GetNotificationTypeById(int notificationTypeId)
 {
     ValidationHelper.GreaterThanZero(notificationTypeId, NotificationMessages.NotificationTypeIdInvalid);
     return(_repository.GetById(notificationTypeId));
 }
Exemplo n.º 5
0
        // GET: /NotificationTypeSelectList/Edit/5
        public ActionResult Edit(int id)
        {
            NotificationType c = _notificationtypeReporRepository.GetById(id);

            return(View(c)); //Compile magic!
        }
Exemplo n.º 6
0
        public ActionResult Add(NotificationModel eventNotification, string addressedTo)
        {
            var notificationIdentity = Mapper.Map <Notification>(eventNotification);

            notificationIdentity.Created = DateTime.Now;
            var notificationType = _notificationTypeRepository.GetById(eventNotification.NotificationTypeId);

            notificationIdentity.NotificationType = notificationType;
            notificationIdentity.Section          = eventNotification.GradeSection;
            if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Personal)
            {
                notificationIdentity.IdGradeAreaUserGeneralSelected    = eventNotification.StudentId;
                notificationIdentity.GradeIdifNotificationTypePersonal = Convert.ToInt32(eventNotification.IdIsGradeAreaGeneralSelected);
                notificationIdentity.TargetStudent = _studentRepository.GetById(eventNotification.StudentId);
            }
            else if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Area)
            {
                notificationIdentity.IdGradeAreaUserGeneralSelected    = Convert.ToInt32(eventNotification.IdIsGradeAreaGeneralSelected);
                notificationIdentity.GradeIdifNotificationTypePersonal = Convert.ToInt32(eventNotification.IdIsGradeAreaGeneralSelected);
            }
            if (addressedTo.IsEmpty() || addressedTo == null)
            {
                addressedTo = "0";
            }
            notificationIdentity.GradeIdifNotificationTypePersonal = Convert.ToInt32(addressedTo);
            notificationIdentity.Users = new List <User>();
            if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Personal)
            {
                AddUsersToPersonalNotification(notificationIdentity);
            }
            if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Grado)
            {
                AddUsersToGradeNotification(notificationIdentity);
            }
            if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Area)
            {
                AddUsersToLevelNotification(notificationIdentity);
            }
            var user =
                _userRepository.GetAllUsers()
                .FirstOrDefault(x => x.Email == _sessionManagement.GetUserLoggedEmail());

            if (user != null)
            {
                notificationIdentity.UserCreatorId   = user.Id;
                notificationIdentity.UserCreatorName = user.DisplayName;
            }
            notificationIdentity.Approved = false;
            if (notificationIdentity.NotificationType != null && notificationIdentity.NotificationType.Id == Personal)
            {
                notificationIdentity.Approved = false;
            }

            if (notificationIdentity.NotificationType != null &&
                _sessionManagement.GetUserLoggedRole().Equals("Administrador"))
            {
                notificationIdentity.Approved = true;
            }

            var email = _sessionManagement.GetUserLoggedEmail();

            notificationIdentity.NotificationCreator =
                _userRepository.FirstOrDefault(x => x.Email.Equals(email));
            _notificationRepository.Create(notificationIdentity);
            const string title   = "Notificación Agregado";
            var          content = "El evento " + eventNotification.NotificationName + " ha sido agregado exitosamente.";

            _viewMessageLogic.SetNewMessage(title, content, ViewMessageType.SuccessMessage);
            return(RedirectToAction("Index"));
        }