Ejemplo n.º 1
0
        private DashboardOrchestrator GetSut(List <VacancySummary> vacancies)
        {
            var timeProviderMock = new Mock <ITimeProvider>();

            timeProviderMock.Setup(t => t.Today).Returns(_today);

            var dashboardProjection = new ProviderDashboard
            {
                Vacancies = vacancies
            };

            var vacancyClientMock = new Mock <IProviderVacancyClient>();

            vacancyClientMock.Setup(c => c.GetDashboardAsync(Ukprn, true))
            .ReturnsAsync(dashboardProjection);

            var userDetails = new User();

            var clientMock = new Mock <IRecruitVacancyClient>();

            clientMock.Setup(c => c.GetUsersDetailsAsync(UserId))
            .ReturnsAsync(userDetails);

            var alertsViewModel   = new AlertsViewModel(null, null);
            var alertsFactoryMock = new Mock <IProviderAlertsViewModelFactory>();

            alertsFactoryMock.Setup(a => a.Create(dashboardProjection, userDetails))
            .Returns(alertsViewModel);

            var orch = new DashboardOrchestrator(vacancyClientMock.Object, timeProviderMock.Object, clientMock.Object, alertsFactoryMock.Object);

            return(orch);
        }
        public ActionResult AddAlert(AlertsViewModel alertModel)
        {
            if (alertModel.Alerts.PercentChange == 0)
            {
                TempData["error"] = "Your entry is invalid. Try entering a positive or negative integer";
                return(RedirectToAction("Index", "Alerts"));
            }

            var currentAlerts = _context.Alerts.Where(t => t.EmailAddress == alertModel.Alerts.EmailAddress);

            if (currentAlerts.ToList().Count >= 2)
            {
                TempData["error"] = "You can not set up more than two alerts";
                return(RedirectToAction("Index", "Alerts"));
            }

            if (currentAlerts.SingleOrDefault(t => t.PercentChange == alertModel.Alerts.PercentChange) == null)
            {
                _context.Alerts.Add(alertModel.Alerts);
                _context.SaveChanges();
            }
            else
            {
                TempData["error"] = "You can not enter the same value as a previously set up alert";
                return(RedirectToAction("Index", "Alerts"));
            }


            return(RedirectToAction("Index", "Alerts"));
        }
Ejemplo n.º 3
0
 public AlertsPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new AlertsViewModel(this);
     SetCurrentLocationMap();
     SetPins();
 }
        public FilterAlertsPopup(AlertsViewModel ViewModel)
        {
            InitializeComponent();

            BindingContext = ViewModel;

            if (ViewModel != null)
            {
                TableSectionAlertLevels.Clear();

                TableSectionAlertLevels.Add(new CommonCategoryCell
                {
                    BindingContext = ViewModel.AllCategory
                });

                foreach (var item in ViewModel.AlertsLevelCategories)
                {
                    var AlertCategoryCell = new AlertCategoryCell
                    {
                        BindingContext = item
                    };

                    TableSectionAlertLevels.Add(AlertCategoryCell);
                }
            }
        }
Ejemplo n.º 5
0
 public Alerts(AlertsViewModel vm)
 {
     InitializeComponent();
     _vm                 = vm;
     DataContext         = _vm;
     _vm.SelectionWindow = this;
     _vm.InitializeAllActive();
     Closing += (sender, args) => _vm.UninitializeAll();
 }
Ejemplo n.º 6
0
 public ShellViewModel(
     ILifetimeScope lifetimeScope,
     IEventAggregatorSubscriptionTracker eventAggregatorSubscriptionTracker,
     AlertsViewModel alerts,
     IDialogConductor dialogConductor) : base(lifetimeScope, eventAggregatorSubscriptionTracker)
 {
     _alerts          = alerts;
     _dialogConductor = dialogConductor;
 }
Ejemplo n.º 7
0
        public void Execute()
        {
            String searchValue = CommonHelper.GetSearchValue(_httpContext);

            AlertsViewModel alertsViewModel = _httpContext.Session[SessionHelper.AlertViewModel] != null ?
                                              new AlertsViewModel().FromXml(_httpContext.Session[SessionHelper.AlertViewModel].ToString()) :
                                              new AlertsViewModel();


            AlertsListState alertsListState = _httpContext.Session[SessionHelper.AlertsListState] != null ?
                                              (AlertsListState)_httpContext.Session[SessionHelper.AlertsListState] :
                                              new AlertsListState();

            if (!InputParameters.ContainsKey("LoanPurposeFilter"))
            {
                throw new ArgumentException("LoanPurposeFilter was expected!");
            }

            alertsListState.LoanPurposeFilter = InputParameters["LoanPurposeFilter"].ToString() == "0" ? "" : InputParameters["LoanPurposeFilter"].ToString();

            UserAccount user = _httpContext.Session[SessionHelper.UserData] != null && ((UserAccount)_httpContext.Session[SessionHelper.UserData]).Username == _httpContext.User.Identity.Name
                                   ? (UserAccount)_httpContext.Session[SessionHelper.UserData]
                                   : UserAccountServiceFacade.GetUserByName(_httpContext.User.Identity.Name);

            if (user == null)
            {
                throw new InvalidOperationException("User is null");
            }

            // on date filter change, reset page number
            alertsListState.CurrentPage = 1;

            FilterViewModel userFilterViewModel = null;

            if ((_httpContext != null) && (_httpContext.Session[SessionHelper.FilterViewModel] != null))
            {
                userFilterViewModel = new FilterViewModel().FromXml(_httpContext.Session[SessionHelper.FilterViewModel].ToString());
            }
            else
            {
                userFilterViewModel = new FilterViewModel();
            }

            alertsViewModel = AlertsDataHelper.RetrieveAlertViewModel(alertsListState,
                                                                      _httpContext.Session[SessionHelper.UserAccountIds] != null
                                                                            ? (List <int>)_httpContext.Session[SessionHelper.UserAccountIds]
                                                                            : new List <int> {
            }, alertsListState.BoundDate, user.UserAccountId, userFilterViewModel.CompanyId, userFilterViewModel.ChannelId, userFilterViewModel.DivisionId, userFilterViewModel.BranchId, searchValue);


            _viewName  = "Queues/_alerts";
            _viewModel = alertsViewModel;

            /* Persist new state */
            _httpContext.Session[SessionHelper.AlertViewModel]  = alertsViewModel.ToXml();
            _httpContext.Session[SessionHelper.AlertsListState] = alertsListState;
        }
        public static AlertsViewModel RetrieveAlertViewModel(AlertsListState alertsListState, List <int> userAccountIds, GridDateFilter dateFilter, int userAccountId, Guid companyid, int channelId, int divisionId, Guid branchId, string searchTerm = null)
        {
            if (alertsListState == null)
            {
                alertsListState = new AlertsListState();
            }

            if (userAccountIds == null)
            {
                userAccountIds = new List <int>();
            }

            var alertsViewData = AlertMessageServiceFacade.RetrieveAlertItemsView(userAccountId, userAccountIds,
                                                                                  alertsListState.CurrentPage,
                                                                                  alertsListState.SortColumn.GetStringValue(),
                                                                                  alertsListState.SortDirection,
                                                                                  alertsListState.BoundDate,
                                                                                  searchTerm,
                                                                                  alertsListState.LoanPurposeFilter,
                                                                                  alertsListState.ActivityTypeFilter,
                                                                                  companyid, channelId, divisionId, branchId
                                                                                  ) ??
                                 new AlertViewData {
                AlertItems = new List <AlertViewItem>(), TotalItems = 0, TotalPages = 0, NumberOfAlerts = 0
            };


            foreach (AlertViewItem alertViewItems in alertsViewData.AlertItems)
            {
                foreach (AlertView alertViewItem in alertViewItems.AlertViewItems)
                {
                    DataForShortProductDescription data =
                        LoanServiceFacade.RetrieveDataForShortProductDescription(alertViewItem.LoanId);

                    alertViewItem.ProgramName = LoanHelper.FormatShortProductDescription(alertViewItem.IsHarp,
                                                                                         ((AmortizationType)data.AmortizationType).GetStringValue(),
                                                                                         data.LoanTerm,
                                                                                         data.FixedRateTerm,
                                                                                         ((MortgageType)data.MortgageType).GetStringValue());
                }
            }
            var alertsViewModel = new AlertsViewModel
            {
                ActivityTypeList = CommonHelper.RetrieveActivityListForQueueFilter(),
                LoanPurposeList  = new List <LoanTransactionType>(Enum.GetValues(typeof(LoanTransactionType)).Cast <LoanTransactionType>().Skip(1)),
                AlertItems       = alertsViewData.AlertItems,
                PageCount        = alertsViewData.TotalPages,
                TotalItems       = alertsViewData.TotalItems,
                NumberOfAlerts   = alertsViewData.NumberOfAlerts
            };

            AlertsGridHelper.ProcessPagingOptions(alertsListState, alertsViewModel);
            AlertsGridHelper.ApplyClassCollection(alertsViewModel);

            return(alertsViewModel);
        }
Ejemplo n.º 9
0
 public async Task <Alert> ToAlertAsync(AlertsViewModel model, bool IsNew)
 {
     return(new Alert
     {
         Id = IsNew ? 0 : model.Id,
         Alert_Description = model.Alert_Description,
         Alert_Date = model.Alert_Date,
         AlertImages = IsNew ? new List <AlertImage>() : model.AlertImages,
         Status = await _dataContext.Statuses.FindAsync(model.Status_id)
     });
 }
Ejemplo n.º 10
0
        public static void ProcessPagingOptions(AlertsListState alertsListState, AlertsViewModel alertsViewModel)
        {
            if (alertsViewModel.PageCount % 10 == 0)
            {
                alertsViewModel.PageGroups = (alertsViewModel.PageCount / 10);
            }
            else
            {
                alertsViewModel.PageGroups = (alertsViewModel.PageCount / 10) + 1;
            }

            alertsViewModel.PageGroups = ( int )alertsViewModel.PageGroups;
            if (alertsViewModel.PageCount % 10 != 0)
            {
                alertsViewModel.LastPageItems = alertsViewModel.PageCount % 10;
            }
            else
            {
                alertsViewModel.LastPageItems = 10;
            }

            alertsViewModel.CurrentPage = alertsListState.CurrentPage;

            if (alertsViewModel.CurrentPage % 10 != 0)
            {
                alertsViewModel.StartPage = ( int )(alertsViewModel.CurrentPage / 10) * 10 + 1;
                if ((( int )((alertsViewModel.CurrentPage) / 10) + 1) == alertsViewModel.PageGroups)
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10 + alertsViewModel.LastPageItems;
                    alertsViewModel.LastPageDots = true;
                }
                else
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10 + 10;
                    alertsViewModel.LastPageDots = false;
                }
            }
            else
            {
                alertsViewModel.StartPage = ( int )((alertsViewModel.CurrentPage - 1) / 10) * 10 + 1;
                if ((( int )((alertsViewModel.CurrentPage - 1) / 10) + 1) == alertsViewModel.PageGroups)
                {
                    alertsViewModel.EndPage      = ( int )(alertsViewModel.CurrentPage / 10) * 10;
                    alertsViewModel.LastPageDots = true;
                }
                else
                {
                    alertsViewModel.EndPage      = ( int )((alertsViewModel.CurrentPage - 1) / 10) * 10 + 10;
                    alertsViewModel.LastPageDots = false;
                }
            }
        }
        public ActionResult DeleteAlert(AlertsViewModel alertModel)
        {
            var alert = new Alerts()
            {
                Id = alertModel.Alerts.Id
            };

            _context.Entry(alert).State = EntityState.Deleted;
            _context.SaveChanges();


            return(RedirectToAction("Index", "Alerts"));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> EditAlert(AlertsViewModel model)
        {
            if (ModelState.IsValid)
            {
                var status = await _converterHelper.ToAlertAsync(model, false);

                _datacontext.Alerts.Update(status);
                await _datacontext.SaveChangesAsync();

                return(RedirectToAction($"AlertList/{model.Status_id}"));
            }

            return(View(model));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> AddAlert(AlertsViewModel model)
        {
            if (ModelState.IsValid)
            {
                var alert = await _converterHelper.ToAlertAsync(model, true);

                _datacontext.Alerts.Add(alert);
                await _datacontext.SaveChangesAsync();

                return(RedirectToAction($"AlertList/{model.Status_id}"));
            }

            return(View(model));
        }
        public void Insert()
        {
            // Arrange - Create a new account view model
            var newAlertsViewModel = new AlertsViewModel()
            {
                Name = "Test Name"
            };


            // Act - send this to the insert method on the account service logic
            var Response = _AlertsService.Insert(newAlertsViewModel, mockUser);


            // Assert
            Assert.IsTrue(Response.Success);
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> AddAlert(int?id)
        {
            var status = await _datacontext.Statuses.FindAsync(id);

            if (id == null || status == null)
            {
                return(NotFound());
            }

            var model = new AlertsViewModel
            {
                Status_id = status.Id,
            };

            return(View(model));
        }
        // GET: Alerts
        public ActionResult Index()
        {
            if (!Request.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Account", action = "Login" }));
            }

            var alerts = _context.Alerts.ToList().Where(t => t.EmailAddress == User.Identity.GetUserName());

            var viewModel = new AlertsViewModel
            {
                Alertses = alerts
            };


            return(View(viewModel));
        }
Ejemplo n.º 17
0
        private DashboardOrchestrator GetSut(List <VacancySummary> vacancies)
        {
            var timeProviderMock = new Mock <ITimeProvider>();

            timeProviderMock.Setup(t => t.Today).Returns(_today);

            var dashboardProjection = new ProviderDashboard
            {
                Vacancies = vacancies
            };

            var vacancyClientMock = new Mock <IProviderVacancyClient>();

            vacancyClientMock.Setup(c => c.GetDashboardAsync(Ukprn, true))
            .ReturnsAsync(dashboardProjection);

            var permissionServiceMock = new Mock <IProviderRelationshipsService>();

            permissionServiceMock.Setup(p => p.GetLegalEntitiesForProviderAsync(Ukprn, OperationType.RecruitmentRequiresReview))
            .ReturnsAsync(new List <EmployerInfo>());

            var userDetails = new User();

            var clientMock = new Mock <IRecruitVacancyClient>();

            clientMock.Setup(c => c.GetUsersDetailsAsync(UserId))
            .ReturnsAsync(userDetails);

            var alertsViewModel   = new AlertsViewModel(null, null);
            var alertsFactoryMock = new Mock <IProviderAlertsViewModelFactory>();

            alertsFactoryMock.Setup(a => a.Create(dashboardProjection, userDetails))
            .Returns(alertsViewModel);

            var orch = new DashboardOrchestrator(vacancyClientMock.Object, timeProviderMock.Object, clientMock.Object, alertsFactoryMock.Object, permissionServiceMock.Object);

            return(orch);
        }
Ejemplo n.º 18
0
        public static void ApplyClassCollection(AlertsViewModel alertsViewModel)
        {
            if (alertsViewModel.AlertItems != null)
            {
                // Business rule
                foreach (var alertItem in alertsViewModel.AlertItems)
                {
                    foreach (var item in alertItem.AlertViewItems)
                    {
                        if (item.LockExpiration < DateTime.Now && item.LockExpiration != DateTime.MinValue)
                        {
                            item.ClassCollection = "alerttablelistduedate";
                        }
                        else
                        {
                            item.ClassCollection = "alerttablelist";
                        }

                        if (item.ExceptionItemMaxWeight != -1)
                        {
                            item.ExceptionClassCollection = item.ExceptionItemMaxWeight < 300
                                ? "exceptionIcon exceptionIcon0"
                                : "exceptionIcon exceptionIcon1";
                        }
                        if (item == alertItem.AlertViewItems.First())
                        {
                            item.ClassCollection = item.ClassCollection + " first last";
                        }

                        if (item == alertItem.AlertViewItems.Last())
                        {
                            item.ClassCollection = item.ClassCollection + " last";
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates an alert
 /// This is also a new window that pops up
 /// </summary>
 /// <param name="userServices"></param>
 /// <param name="alertServices"></param>
 /// <param name="alerts"></param>
 public AlertsWindow(UserServices userServices, AlertServices alertServices, MaterialServices materialServices, ProductServices productServices, MaterialsProductServices materialsProductServices, SaleServices saleServices, List <Alert> alerts)
 {
     InitializeComponent();
     DataContext = new AlertsViewModel(this, userServices, alertServices, materialServices, productServices, materialsProductServices, saleServices, alerts);
 }
Ejemplo n.º 20
0
        public void AddAlert(AlertsViewModel alert)
        {
            //PatientAlerts pa = new PatientAlerts();
            //PatientFallRisks pfr = new PatientFallRisks();
            //using (var context = new WCTCHealthSystemContext())
            //{
            //    using (var transaction = context.Database.BeginTransaction())
            //    {
            //        try
            //        {
            //            // do your changes

            //            pa.AlertTypeId = alert.AlertTypeId;
            //            pa.PatientAlertId = alert.PatientAlertId;
            //            pa.Mrn = alert.Mrn;
            //            pa.LastModified = alert.LastModified;
            //            pa.StartDate = alert.StartDate;
            //            pa.EndDate = alert.EndDate;
            //            pa.Comments = alert.Comments;
            //            context.PatientAlerts.Add(pa);
            //            context.SaveChanges();

            //            pfr.FallRiskId = alert.FallRiskId;
            //            pfr.PatientAlertId = alert.PatientAlertId;
            //            pfr.FallRiskId = alert.FallRiskId;
            //            pfr.LastModified = alert.LastModified;
            //            context.PatientFallRisks.Add(pfr);
            //            context.SaveChanges();

            //            //            // do another changes
            //            //            context.SaveChanges();

            //            transaction.Commit();
            //        }
            //        catch (Exception ex)
            //        {
            //            Console.WriteLine("The following error appeared: " + ex.Message);
            //            transaction.Rollback();

            //            //Log, handle or absorbe I don't care ^_^
            //        }
            //    }
            //}


            Debug.WriteLine("this is fallRiskId " + alert.FallRiskId);
            Debug.WriteLine("this is alert.PatientAlertId " + alert.PatientAlertId);
            Debug.WriteLine("this is LastModified " + alert.LastModified);

            PatientAlerts pa = new PatientAlerts();

            pa.AlertTypeId    = alert.AlertTypeId;
            pa.PatientAlertId = alert.PatientAlertId;
            pa.Mrn            = alert.Mrn;
            pa.LastModified   = alert.LastModified;
            pa.StartDate      = alert.StartDate;
            pa.EndDate        = alert.EndDate;
            pa.Comments       = alert.Comments;
            context.PatientAlerts.Add(pa);
            context.SaveChanges();

            PatientFallRisks pfr = new PatientFallRisks();

            pfr.FallRiskId     = alert.FallRiskId;
            pfr.PatientAlertId = alert.PatientAlertId;
            pfr.LastModified   = alert.LastModified;
            context.PatientFallRisks.Add(pfr);
            context.SaveChanges();

            //PatientRestrictions pr = new PatientRestrictions();
            //pr.RestrictionTypeId = alert.RestrictionTypeId;
            //pr.PatientAlertId = alert.PatientAlertId;
            //pr.LastModified = alert.LastModified;
            //context.PatientRestrictions.Add(pr);
            //context.SaveChanges();
            //}

            //PatientAllergy pall = new PatientAllergy();
            //pall.AllergenId = alert.AllergenId;
            //pall.ReactionId = alert.ReactionId;
            //pall.PatientAlertId = alert.PatientAlertId;
            //pall.LastModified = alert.LastModified;
            //context.PatientAllergy.Add(pall);
            //context.SaveChanges();
        }