Exemplo n.º 1
0
        public IActionResult ClearAllUnitEvents(ViewLogsView model)
        {
            if (model.ConfirmClearAll)
            {
                _unitsService.DeleteStatesForUnit(model.Unit.UnitId);
            }

            return(RedirectToAction("ViewEvents", new { unitId = model.Unit.UnitId }));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ClearAllUnitEvents(ViewLogsView model, CancellationToken cancellationToken)
        {
            if (model.ConfirmClearAll)
            {
                await _unitsService.DeleteStatesForUnitAsync(model.Unit.UnitId, cancellationToken);
            }

            return(RedirectToAction("ViewEvents", new { unitId = model.Unit.UnitId }));
        }
Exemplo n.º 3
0
        public IActionResult ViewEvents(int unitId)
        {
            if (!_authorizationService.CanUserViewUnit(UserId, unitId))
            {
                Unauthorized();
            }

            var model = new ViewLogsView();

            model.Unit = _unitsService.GetUnitById(unitId);

            return(View(model));
        }
Exemplo n.º 4
0
        public IActionResult ViewLogs(int unitId)
        {
            if (!_authorizationService.CanUserViewUnit(UserId, unitId))
            {
                Unauthorized();
            }

            var model = new ViewLogsView();

            model.Unit       = _unitsService.GetUnitById(unitId);
            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);

            if (model.Unit == null)
            {
                Unauthorized();
            }

            model.Logs = _unitsService.GetLogsForUnit(model.Unit.UnitId);

            return(View(model));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> ViewLogs(int unitId)
        {
            if (!await _authorizationService.CanUserViewUnitAsync(UserId, unitId))
            {
                Unauthorized();
            }

            var model = new ViewLogsView();

            model.Unit = await _unitsService.GetUnitByIdAsync(unitId);

            model.Department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);

            if (model.Unit == null)
            {
                Unauthorized();
            }

            model.Logs = await _unitsService.GetLogsForUnitAsync(model.Unit.UnitId);

            return(View(model));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> ViewEvents(int unitId)
        {
            if (!await _authorizationService.CanUserViewUnitAsync(UserId, unitId))
            {
                Unauthorized();
            }

            var model = new ViewLogsView();

            model.Unit = await _unitsService.GetUnitByIdAsync(unitId);

            model.OSMKey = Config.MappingConfig.OSMKey;
            var address = await _departmentSettingsService.GetBigBoardCenterAddressDepartmentAsync(DepartmentId);

            var gpsCoordinates = await _departmentSettingsService.GetBigBoardCenterGpsCoordinatesDepartmentAsync(DepartmentId);

            var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);

            double?centerLat = null;
            double?centerLon = null;

            if (!String.IsNullOrWhiteSpace(gpsCoordinates))
            {
                string[] coordinates = gpsCoordinates.Split(char.Parse(","));

                if (coordinates.Count() == 2)
                {
                    double newLat;
                    double newLon;
                    if (double.TryParse(coordinates[0], out newLat) && double.TryParse(coordinates[1], out newLon))
                    {
                        centerLat = newLat;
                        centerLon = newLon;
                    }
                }
            }

            if (!centerLat.HasValue && !centerLon.HasValue && address != null)
            {
                string coordinates = await _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3}", address.Address1,
                                                                                                   address.City, address.State, address.PostalCode));

                if (!String.IsNullOrEmpty(coordinates))
                {
                    double newLat;
                    double newLon;
                    var    coordinatesArr = coordinates.Split(char.Parse(","));
                    if (double.TryParse(coordinatesArr[0], out newLat) && double.TryParse(coordinatesArr[1], out newLon))
                    {
                        centerLat = newLat;
                        centerLon = newLon;
                    }
                }
            }

            if (!centerLat.HasValue && !centerLon.HasValue && department.Address != null)
            {
                string coordinates = await _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3}", department.Address.Address1,
                                                                                                   department.Address.City,
                                                                                                   department.Address.State,
                                                                                                   department.Address.PostalCode));

                if (!String.IsNullOrEmpty(coordinates))
                {
                    double newLat;
                    double newLon;
                    var    coordinatesArr = coordinates.Split(char.Parse(","));
                    if (double.TryParse(coordinatesArr[0], out newLat) && double.TryParse(coordinatesArr[1], out newLon))
                    {
                        centerLat = newLat;
                        centerLon = newLon;
                    }
                }
            }

            if (!centerLat.HasValue || !centerLon.HasValue)
            {
                centerLat = 39.14086268299356;
                centerLon = -119.7583809782715;
            }

            model.CenterLat = centerLat.Value;
            model.CenterLon = centerLon.Value;

            return(View(model));
        }