Esempio n. 1
0
        public async Task <Result> Handle(ReplyToObservationCommand request, CancellationToken token)
        {
            var observation = await _context.Observations.SingleOrDefaultAsync(b => b.Id == request.ObservationId, token);

            if (observation == null)
            {
                return(Failure("L'observation à laquelle répondre est introuvable."));
            }

            var currentUser = _currentUserService.GetCurrentUserInfo();

            if (!currentUser.Succeeded)
            {
                return(Failure(currentUser));
            }

            if (!currentUser.Data.IsInRole(_roleOptions.Producer.Value) &&
                observation.UserId != currentUser.Data.Id)
            {
                return(Failure("Vous n'êtes pas autorisé à accéder à cette ressource."));
            }

            var user = await _context.Users.SingleOrDefaultAsync(u => u.Id == request.RequestUser.Id, token);

            observation.AddReply(request.Comment, user);

            await _context.SaveChangesAsync(token);

            return(Success());
        }
Esempio n. 2
0
        private void SaveAudit(IEnumerable <PropertyValueTracker> entity, CrudAction changeType)
        {
            var audit = new DataAudit()
            {
                ChangedBy   = currentUserService.GetCurrentUserInfo()?.NetworkID,
                ChangedDate = DateTime.Now,
                ChangeType  = (int)changeType,
                EntityName  = entity.GetType().FullName,
                NewInfo     = entity.ToXMLString()
            };

            repository.Save(audit);
        }
Esempio n. 3
0
        public IActionResult Get()
        {
            var formInformation = new FormInformation <AssignmentCriteria>()
            {
                Model = new AssignmentCriteria()
                {
                    PersonID = currentUserService.GetCurrentUserInfo().ID
                },
            };

            formService.UpdateFormInformation(formInformation);

            return(Json(new FilteredListInformation <AssignmentViewModel, AssignmentCriteria>()
            {
                SortDirection = ListSortDirection.Ascending,
                SortExpression = nameof(AssignmentViewModel.AssignedOn),
                EmptyDataMessage = "No Assignments found.",
                AllowManualRefresh = true,
                ShowCount = true,
                Title = "To-Do items",
                ShowFilterForm = true,
                FilterFormInformation = formInformation,
            }));
        }
 public ApplicationPerson Get()
 {
     return(currentUserService.GetCurrentUserInfo());
 }