Ejemplo n.º 1
0
        public async Task <string> Handle(ChangeNoteStatusCommand cmd)
        {
            if (string.IsNullOrEmpty(cmd.FileId))
            {
                throw new ArgumentNullException("FileId is required");
            }
            if (string.IsNullOrEmpty(cmd.NoteId))
            {
                throw new ArgumentNullException("NoteId is required");
            }

            var file = (await caseRepository.QueryCase(new Resources.Cases.EvacuationFilesQuery
            {
                FileId = cmd.FileId,
            })).Items.Cast <Resources.Cases.Evacuations.EvacuationFile>().SingleOrDefault();

            if (file == null)
            {
                throw new NotFoundException($"Evacuation File {cmd.FileId} not found", cmd.FileId);
            }

            var note = file.Notes.Where(n => n.Id == cmd.NoteId).SingleOrDefault();

            if (note == null)
            {
                throw new NotFoundException($"Evacuation File Note {cmd.NoteId} not found", cmd.NoteId);
            }

            note.IsHidden = cmd.IsHidden;
            var id = (await caseRepository.ManageCase(new SaveEvacuationFileNote {
                FileId = cmd.FileId, Note = note
            })).Id;

            return(id);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <RegistrationResult> > SetFileNoteHiddenStatus(string fileId, string noteId, bool isHidden)
        {
            if (!UserCanHideNote())
            {
                return(BadRequest(new ProblemDetails {
                    Detail = "You do not have sufficient permissions to edit a note's hidden status."
                }));
            }

            var cmd = new ChangeNoteStatusCommand
            {
                NoteId   = noteId,
                FileId   = fileId,
                IsHidden = isHidden
            };

            var id = await messagingClient.Send(cmd);

            return(Ok(new EvacuationFileNotesResult {
                Id = id
            }));
        }