public async Task <IActionResult> ResetPassword(ResetPasswordViewModel model)
        {
            string msg;

            if (!ModelState.IsValid)
            {
                msg = "Your password was not reset. Please fix the errors shown below.";
                ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");
                return(View(model));
            }

            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user != null && user.Active)
            {
                var result = await _userManager.ResetPasswordAsync(user, model.Code, model.Password);

                if (result.Succeeded)
                {
                    msg = "Your password has been reset. Please sign in.";
                    TempData.SaveAlertForSession(msg, AlertStatus.Success, "Success");
                    return(RedirectToAction(nameof(AccountController.Login)));
                }
                AddErrors(result);
            }

            msg = "An error occurred. Your password was not reset.";
            ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");
            return(View());
        }
예제 #2
0
        public async Task <AlertViewModel> Create(AlertViewModel viewModel)
        {
            var systemAlerts = new Alert
            {
                Title       = viewModel.Title,
                Description = viewModel.Description,
                AlertBy     = viewModel.AlertBy,
                AlertTo     = viewModel.AlertTo,
                IsRead      = viewModel.IsRead,
                IsActive    = viewModel.IsRead,
                CreatedOn   = DateTime.Now
            };

            systemAlerts = this.SystemAlertsRepository.Add(systemAlerts);

            if (systemAlerts.AlertId > 0)
            {
                viewModel.AlertId = systemAlerts.AlertId;
            }
            else
            {
                viewModel.AlertId = 0;
            }

            return(viewModel);
        }
예제 #3
0
        public async Task <AlertViewModel> Update(AlertViewModel updateModel)
        {
            var systemAlerts = this._systemAlertsRepository.Find(updateModel.AlertId);

            if (systemAlerts != null)
            {
                systemAlerts.Title          = updateModel.Title;
                systemAlerts.Description    = updateModel.Description;
                systemAlerts.AlertTo        = updateModel.AlertTo;
                systemAlerts.AlertBy        = updateModel.AlertBy;
                systemAlerts.LastModifiedOn = DateTime.Now;
                systemAlerts.IsRead         = updateModel.IsRead;
                systemAlerts.IsActive       = updateModel.IsRead;
                systemAlerts = this._systemAlertsRepository.Update(systemAlerts);
                return(new AlertViewModel
                {
                    AlertId = systemAlerts.AlertId,
                });
            }
            else
            {
                updateModel.AlertId = 0;
            }

            return(updateModel);
        }
예제 #4
0
        public AlertPage()
        {
            InitializeComponent();
            BindingContext = _viewModel = new AlertViewModel();

            var itens = new List <Alert>()
            {
                new Alert()
                {
                    Id = 1, Message = "Você possui uma nova mensagem no Chat.", Type = AlertType.Warning, ProcessingMethod = AlertProcessingMethod.SceneChange, IdImageProcesses = 1
                },
                new Alert()
                {
                    Id = 2, Message = "Mudança de cena detectada, verifique.", Type = AlertType.Critical, ProcessingMethod = AlertProcessingMethod.SceneChange, IdImageProcesses = 2
                },
                new Alert()
                {
                    Id = 3, Message = "Carro desconhecido detectado, verifique.", Type = AlertType.Critical, ProcessingMethod = AlertProcessingMethod.UnkownCar, IdImageProcesses = 3
                },
                new Alert()
                {
                    Id = 4, Message = "Pessoa desconhecida detectada, verifique com urgência!", Type = AlertType.Panic, ProcessingMethod = AlertProcessingMethod.UnkownPeople, IdImageProcesses = 4
                }
            };

            _viewModel.Alerts.AddRange(itens);
            _viewModel.Alerts.CollectionChanged += (sender, e) =>
            {
                var target = _viewModel.Alerts[_viewModel.Alerts.Count - 1];
                AlertListView.ScrollTo(target, ScrollToPosition.End, true);
            };
        }
        public void PushNotification(string userId, AlertViewModel data)
        {
            var devices = MobileDevice_GetByUserId(userId).ToList();

            //_log.InfoFormat("Total Device of {0}: {1}",userId,devices.Count);
            if (devices.Count > 0)
            {
                Parallel.ForEach(devices, (item) =>
                {
                    PushMessage msg = new PushMessage();
                    msg.to          = item.Token;
                    msg.title       = data.Title;
                    msg.body        = data.Content;
                    msg.data        = new AlertData()
                    {
                        ReferId = data.ReferId,
                        Type    = data.Type
                    };
                    //msg.ttl = DateTime.Now.ToUnixTimeMiliseconds();
                    //msg.expiration = DateTime.Now.AddDays(1).ToUnixTimeMiliseconds();
                    //push to device--
                    new MobileMessageService().Push(msg);
                    //_log.Info(Newtonsoft.Json.JsonConvert.SerializeObject(msg));
                });
            }
        }
예제 #6
0
        public ActionResult ViewAlert(Guid id)
        {
            try
            {
                var alert = this.AmiClient.GetAlerts(a => a.Key == id).CollectionItem.FirstOrDefault();

                if (alert == null)
                {
                    TempData["error"] = Locale.AlertNotFound;

                    return(RedirectToAction("Index"));
                }

                var viewModel = new AlertViewModel(alert);

                return(View(viewModel));
            }
            catch (Exception e)
            {
                Trace.TraceError($"Unable to view alert: {e}");
            }

            TempData["error"] = Locale.AlertNotFound;

            return(RedirectToAction("Index"));
        }
예제 #7
0
        // GET: Rackaz/AcademicMajor
        public ActionResult AlertArchive()
        {
            var reportAlerts = _alertService.GetReportAlerts(CurrentUser.Area, true);

            if (!reportAlerts.Success)
            {
                return(Error(reportAlerts));
            }

            var gradeAlerts = _alertService.GetGradeAlerts(CurrentUser.Area, true);

            if (!gradeAlerts.Success)
            {
                return(Error(gradeAlerts));
            }

            var lateAlerts = _alertService.GetLateTutorAlerts(CurrentUser.Area, true);

            if (!lateAlerts.Success)
            {
                return(Error(lateAlerts));
            }
            var model = new AlertViewModel(lateAlerts.Data, gradeAlerts.Data, reportAlerts.Data);

            return(View(model));
        }
예제 #8
0
            public void LoadCellValues(AlertViewModel alert)
            {
                ExceptionUtility.Try(() =>
                {
                    _dateTimeLabel.Text = alert.DisplayDate;
                    _dateTimeLabel.SizeToFit();

                    if (alert.Active)
                    {
                        _descriptionLabel.SetFontAndColor(AlertTextBoldFont);
                    }
                    else
                    {
                        _descriptionLabel.SetFontAndColor(AlertTextNormalFont);
                    }

                    if (alert.ShowRed)
                    {
                        _descriptionLabel.TextColor = Colors.ErrorTextColor;
                    }
                    else
                    {
                        _descriptionLabel.TextColor = Colors.StandardTextColor;
                    }

                    _descriptionLabel.Text = alert.DisplayText;
                    _descriptionLabel.SizeToFit();

                    _blueCircleImageView.Hidden = (!alert.Active);
                });
            }
예제 #9
0
        private async void ShowAlert(AlertViewModel alert)
        {
            await Task.Yield();

            MessageBox.Show(alert.Message, alert.Caption,
                            MessageBoxButton.OK, MessageBoxImage.Information);
            alert.AcceptCommand.Invoke(this);
        }
예제 #10
0
 internal void AlertDanger(string title, string message)
 {
     TempData["Alert"] = new AlertViewModel
     {
         Type    = "danger",
         Title   = title,
         Message = message
     };
 }
예제 #11
0
        public async Task Show(string message)
        {
            _alertViewModel         = new AlertViewModel();
            _alertViewModel.Message = message;
            DataContext             = _alertViewModel;

            //show the dialog
            var result = await DialogHost.Show(this, "RootDialog", ClosingEventHandler);
        }
예제 #12
0
 internal void AlertSuccess(string title, string message)
 {
     TempData["Alert"] = new AlertViewModel
     {
         Type    = "success",
         Title   = title,
         Message = message
     };
 }
예제 #13
0
 public DailyExecutionReportViewModel()
 {
     NLSList = new List<NLSViewModel>();
     Highlights = new List<HighlightViewModel>();
     Alert = new AlertViewModel();
     Weather = new WeatherViewModel();
     HighlightGroups = new List<HighlightGroupViewModel>();
     HighlightGroupTemplates = new List<HighlightGroupViewModel>();
 }
예제 #14
0
 public TopLevelViewControllerBase(string nibName, Foundation.NSBundle bundle, AlertViewModel alert) : base(nibName, null)
 {
     ExceptionUtility.Try(() =>
     {
         SubscribeConnectionEvents();
         this.TabBar        = new TabBarView(this);
         this.ConnectionBar = new ConnectionStateDebugView(this);
         this.ReconBar      = new ReconnectingView(this);
         AlertID            = alert;
     });
 }
예제 #15
0
        public async Task <IActionResult> DaysToClosureByOffice(DateTime?beginDate, DateTime?endDate)
        {
            var currentUser = await GetCurrentUserAsync();

            var today = DateTime.Today;

            if (!endDate.HasValue)
            {
                endDate = new DateTime(today.Year - Convert.ToInt32(today.Month < 7), 6, 30);
            }

            if (!beginDate.HasValue)
            {
                beginDate = endDate.Value.AddYears(-1).AddDays(1);
            }

            IEnumerable <ReportDaysToClosureByOfficeViewModel.OfficeList> officeList = null;

            if (endDate < beginDate)
            {
                var msg = "The beginning date must precede the end date.";
                ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");
            }
            else
            {
                officeList = await _context.LookupOffices.AsNoTracking()
                             .Where(e => e.Active)
                             .OrderBy(e => e.Name)
                             .Select(e => new ReportDaysToClosureByOfficeViewModel.OfficeList(e))
                             .ToListAsync();

                foreach (var office in officeList)
                {
                    office.Complaints = await _context.Complaints.AsNoTracking()
                                        .Where(e => e.ComplaintClosed)
                                        .Where(e => !e.Deleted)
                                        .Where(e => e.CurrentOfficeId == office.Id)
                                        .Where(e => e.DateComplaintClosed >= beginDate)
                                        .Where(e => e.DateComplaintClosed <= endDate)
                                        .OrderBy(e => e.DateComplaintClosed)
                                        .Select(e => new ReportDaysToClosureByOfficeViewModel.ComplaintList(e))
                                        .ToListAsync();
                }
            }

            return(View("DaysToClosureByOffice", new ReportDaysToClosureByOfficeViewModel
            {
                Title = "Days To Closure By Office",
                Offices = officeList,
                BeginDate = beginDate,
                EndDate = endDate,
                CurrentAction = nameof(DaysToClosureByOffice)
            }));
        }
예제 #16
0
        public async Task <IActionResult> ComplaintsByCounty(DateTime?beginDate, DateTime?endDate)
        {
            var currentUser = await GetCurrentUserAsync();

            var today = DateTime.Today;

            if (!beginDate.HasValue)
            {
                beginDate = new DateTime(today.Year, today.Month, 1).AddMonths(-1);
            }

            if (!endDate.HasValue)
            {
                endDate = new DateTime(today.Year, today.Month, 1).AddDays(-1);
            }

            IEnumerable <ReportComplaintsByCountyViewModel.CountyList> countyList = null;

            if (endDate < beginDate)
            {
                var msg = "The beginning date must precede the end date.";
                ViewData["AlertMessage"] = new AlertViewModel(msg, AlertStatus.Error, "Error");
            }
            else
            {
                countyList = await _context.LookupCounties.AsNoTracking()
                             .OrderBy(e => e.Name)
                             .Select(e => new ReportComplaintsByCountyViewModel.CountyList(e))
                             .ToListAsync();

                foreach (var county in countyList)
                {
                    county.Complaints = await _context.Complaints.AsNoTracking()
                                        .Include(e => e.CurrentOwner)
                                        .Where(e => !e.Deleted)
                                        .Where(e => e.ComplaintCountyId == county.Id)
                                        .Where(e => e.DateReceived >= beginDate)
                                        .Where(e => e.DateReceived <= endDate)
                                        .OrderBy(e => e.DateReceived)
                                        .Select(e => new ReportComplaintsByCountyViewModel.ComplaintList(e))
                                        .ToListAsync();
                }
            }

            return(View("ComplaintsByCounty", new ReportComplaintsByCountyViewModel
            {
                Title = "All Complaints By County",
                Counties = countyList,
                BeginDate = beginDate,
                EndDate = endDate,
                CurrentAction = nameof(ComplaintsByCounty)
            }));
        }
예제 #17
0
        public async Task <IActionResult> OnPostSaveRequestAsync([FromBody] RMARequestViewModel data)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var rmaRequest = _context.RMARequests.FirstOrDefault(x => x.Id == data.Id);

            rmaRequest.CustomerERPId        = data.CustomerERPId;
            rmaRequest.CustomerName         = data.CustomerName;
            rmaRequest.CustomerContactEmail = data.CustomerContactEmail;
            rmaRequest.DefectPhenomenon     = data.DefectPhenomenon;
            rmaRequest.CustomerContact      = data.CustomerContact;
            rmaRequest.InvoiceNumber        = data.InvoiceNumber;
            rmaRequest.Remark = data.Remark;
            //rmaRequest.Status = data.Status;
            rmaRequest.RMAReport         = data.RMAReport;
            rmaRequest.SalesPersonUserId = data.SalesPersonUserId;

            if (rmaRequest.RMANumber == null && data.RMANumber != null)
            {
                rmaRequest.RMANumber = data.RMANumber;
                rmaRequest.RMANumberIssuedByUserId = user.Id;
                rmaRequest.RMAIssueDate            = DateTime.UtcNow;
            }

            // prepare partnumbers & serialnumbers
            rmaRequest.PartSerialNumbers = string.Empty;
            foreach (var item in data.RMARequestItems)
            {
                if (!string.IsNullOrEmpty(item.PartNumber) && !string.IsNullOrEmpty(item.SerialNumber))
                {
                    rmaRequest.PartSerialNumbers += item.PartNumber + "," + item.SerialNumber + ";";
                }
            }

            _context.SaveChanges();

            // Set TempData for notification manually
            AlertViewModel alert = new AlertViewModel
            {
                AlertType  = "success",
                AlertTitle = "You are redirected!",
                AlertBody  = string.Format("RMA Number: {0} with Id: {1} modified successfully.", rmaRequest.RMANumber, rmaRequest.Id)
            };

            TempData.Put <AlertViewModel>("alert", alert);
            return(new JsonResult(string.Format("RMA Number: {0} with Id: {1} modified successfully.", rmaRequest.RMANumber, rmaRequest.Id)));
        }