Exemplo n.º 1
0
        public IActionResult AddLog(AddLogView model)
        {
            if (!_authorizationService.CanUserViewUnit(UserId, model.Log.UnitId))
            {
                Unauthorized();
            }

            if (ModelState.IsValid)
            {
                model.Log.Narrative = System.Net.WebUtility.HtmlDecode(model.Log.Narrative);
                _unitsService.SaveUnitLog(model.Log);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddLog(AddLogView model, CancellationToken cancellationToken)
        {
            if (!await _authorizationService.CanUserViewUnitAsync(UserId, model.Log.UnitId))
            {
                Unauthorized();
            }

            if (ModelState.IsValid)
            {
                model.Log.Narrative = System.Net.WebUtility.HtmlDecode(model.Log.Narrative);
                await _unitsService.SaveUnitLogAsync(model.Log, cancellationToken);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public IActionResult AddLog(int unitId)
        {
            var model = new AddLogView();
            var unit  = _unitsService.GetUnitById(unitId);

            if (unit == null)
            {
                Unauthorized();
            }

            if (!_authorizationService.CanUserViewUnit(UserId, unitId))
            {
                Unauthorized();
            }

            model.Log           = new UnitLog();
            model.Log.Timestamp = DateTime.UtcNow;
            model.Log.UnitId    = unit.UnitId;
            model.UnitName      = unit.Name;

            return(View(model));
        }
Exemplo n.º 4
0
        private void AddLog(object obj)
        {
            if (currentTour != null)
            {
                AddLogView addLogView = new AddLogView();
                addLogView.DataContext      = addLogViewModel;
                addLogViewModel.CurrentTour = CurrentTour;

                bool?dialogResult = addLogView.ShowDialog();
                if (!(bool)dialogResult)
                {
                    string _log = "{\"logAdded\":[Tour: \"" + CurrentTour.Name + "\"],\"successfully\":{1}}";
                    log.Info(_log);

                    tours.Clear();
                    RefreshingListItems();
                }
            }
            else
            {
                return;
            }
        }
Exemplo n.º 5
0
        public System.Windows.Window GetWindow()
        {
            AddLogView view = new AddLogView();

            return(view);
        }