Exemplo n.º 1
0
        public ActionResult _Search()
        {
            var model = new EmailNotificationSearchModel
            {
                NotificationTypes = EditionCompletenessNotificationTypes(),
                EmailSendingDate  = DateTime.Today
            };

            return(PartialView(model));
        }
Exemplo n.º 2
0
        public ActionResult _Search(EmailNotificationSearchModel searchModel)
        {
            //if ((searchModel.NotificationTypeIds == null || !searchModel.NotificationTypeIds.Any()))
            //    ModelState.AddModelError("FilterOptions", "At least one filter option must be applied.");

            //// If more than one apps are selected then roles will be ignored in search.
            //if (searchModel.ApplicationIds != null && searchModel.ApplicationIds.Length > 1)
            //    searchModel.RoleIds = null;

            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, message = ModelState.GetErrors() }, JsonRequestBehavior.AllowGet));
            }

            var model = GetEmailNotificationListItems(searchModel);

            return(Json(new { success = true, data = this.RenderRazorViewToString("_List", model) }));
        }
Exemplo n.º 3
0
        private IList <EmailNotificationListItemModel> GetEmailNotificationListItems(EmailNotificationSearchModel model)
        {
            var notifications = new List <EmailNotificationListItemModel>();

            if (model.NotificationTypes == null)
            {
                model.NotificationTypes = EditionCompletenessNotificationTypes().ToArray();
            }

            if (model.DayRange > 0)
            {
                model.EmailSendingDate = null;
            }

            foreach (var notifType in model.NotificationTypes)
            {
                var deviationInDays = Convert.ToInt32((DateTime.Today - model.EmailSendingDate).GetValueOrDefault().TotalDays);
                if (notifType.GetAttribute <NotificationAttribute>().CheckDaysType == NotificationAttribute.CheckDaysTypes.Passed)
                {
                    deviationInDays *= -1;
                }

                if (notifType.GetAttribute <CompletenessNotificationTypeAttribute>() != null)
                {
                    var minFinancialYear = WebConfigHelper.MinFinancialYear;
                    var statuses         = Utility.Constants.DefaultValidEditionStatusesForCed;
                    var eventTypes       = notifType.GetAttribute <NotificationAttribute>().EventTypes.Select(x => x.GetDescription()).ToArray();
                    var eventActivities  = Utility.Constants.ValidEventActivitiesToNotify;
                    var checkDays        = _emailNotificationHelper.GetCheckDays(notifType);

                    foreach (var checkDay in checkDays)
                    {
                        var editionsToNotify = EditionServices.GetEditionsByNotificationType(checkDay - deviationInDays, model.DayRange, notifType, minFinancialYear, statuses, eventTypes, eventActivities, model.EventId);

                        AddEditionsToNotificationList(notifications, editionsToNotify, notifType, checkDay);
                    }
                }
            }

            return(notifications);
        }