Ejemplo n.º 1
0
        public Action Create(
            Participant createdBy,
            Participant assignedTo,
            string description,
            DateTimeOffset dueDate,
            string title,
            Priority priority,
            Question question
            )
        {
            DateTimeOffset createDate = DateTimeOffset.UtcNow;

            Action newAction = new Action
            {
                CreateDate  = createDate,
                AssignedTo  = assignedTo,
                CreatedBy   = createdBy,
                Description = description,
                DueDate     = dueDate,
                OnHold      = false,
                Completed   = false,
                Priority    = priority,
                Title       = title,
                Question    = question
            };

            _context.Actions.Add(newAction);

            _context.SaveChanges();
            return(newAction);
        }
Ejemplo n.º 2
0
        private static List <Action> GetActions()
        {
            var action1 = new Action
            {
                Title       = "Action1",
                Description = "Description",
                Priority    = Priority.High,
                OnHold      = false,
                DueDate     = DateTime.UtcNow,
                CreateDate  = DateTime.UtcNow,
                AssignedTo  = Participants[0],
                CreatedBy   = Participants[0],
                Question    = Questions[0]
            };
            var action2 = new Action
            {
                Title       = "Action2",
                Description = "Description",
                Priority    = Priority.Medium,
                OnHold      = false,
                DueDate     = DateTime.UtcNow,
                CreateDate  = DateTime.UtcNow,
                AssignedTo  = Participants[0],
                CreatedBy   = Participants[0],
                Question    = Questions[0]
            };

            return(new List <Action>(new Action[] { action1, action2 }));
        }
Ejemplo n.º 3
0
        public Action EditAction(
            Action action,
            Participant assignedTo,
            string description,
            DateTimeOffset dueDate,
            string title,
            bool onHold,
            bool completed,
            Priority priority
            )
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            action.AssignedTo  = assignedTo;
            action.Description = description;
            action.DueDate     = dueDate;
            action.Title       = title;
            action.OnHold      = onHold;
            action.Completed   = completed;
            action.Priority    = priority;

            _context.Actions.Update(action);
            _context.SaveChanges();

            return(action);
        }
Ejemplo n.º 4
0
 public Action SetVoid(Action action, bool newStatus)
 {
     action.IsVoided = newStatus;
     _context.Actions.Update(action);
     _context.SaveChanges();
     return(action);
 }
Ejemplo n.º 5
0
        public Note CreateNote(string actionId, string text)
        {
            IQueryable <Action> queryableAction = _actionService.GetAction(actionId);
            Action     action     = queryableAction.First();
            Evaluation evaluation = queryableAction.Select(a => a.Question.Evaluation).First();

            return(_noteService.Create(CurrentUser(evaluation), text, action));
        }
Ejemplo n.º 6
0
        public Action EditAction(string actionId, string assignedToId, string description, DateTimeOffset dueDate, string title, bool onHold, bool completed, Priority priority)
        {
            IQueryable <Action> queryableAction = _actionService.GetAction(actionId);
            Action action = queryableAction.First();

            Participant assignedTo = _participantService.GetParticipant(assignedToId);

            return(_actionService.EditAction(action, assignedTo, description, dueDate, title, onHold, completed, priority));
        }
Ejemplo n.º 7
0
        public ClosingRemark CreateClosingRemark(string actionId, string text)
        {
            IQueryable <Action> queryableAction = _actionService.GetAction(actionId);
            Action     action     = queryableAction.First();
            Evaluation evaluation = queryableAction.Select(a => a.Question.Evaluation).First();

            Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead };
            AssertCanPerformMutation(evaluation, canBePerformedBy);

            return(_closingRemarkService.Create(CurrentUser(evaluation), text, action));
        }
Ejemplo n.º 8
0
        public IQueryable <Action> GetAction(string actionId)
        {
            IQueryable <Action> queryableAction = _context.Actions.Where(action => action.Id.Equals(actionId));
            Action action = queryableAction.FirstOrDefault();

            if (action == null)
            {
                throw new NotFoundInDBException($"Action not found: {actionId}");
            }
            return(queryableAction);
        }
Ejemplo n.º 9
0
        public void VoidAction()
        {
            ActionService actionService = new ActionService(fixture.context);

            Action action = actionService.GetAll().First();

            Action voidedAction = actionService.SetVoid(action, true);

            Assert.Equal(action.Id, voidedAction.Id);
            Assert.True(voidedAction.IsVoided);
        }
Ejemplo n.º 10
0
        public Action EditAction(string actionId, string assignedToId, string description, DateTimeOffset dueDate, string title, bool onHold, bool completed, Priority priority)
        {
            IQueryable <Action> queryableAction = _actionService.GetAction(actionId);
            Action     action     = queryableAction.First();
            Evaluation evaluation = queryableAction.Select(q => q.Question.Evaluation).First();

            Role[] canBePerformedBy = { Role.Facilitator, Role.Participant, Role.OrganizationLead };
            AssertCanPerformMutation(evaluation, canBePerformedBy);

            Participant assignedTo = _participantService.GetParticipant(assignedToId);

            return(_actionService.EditAction(action, assignedTo, description, dueDate, title, onHold, completed, priority));
        }
Ejemplo n.º 11
0
        public Action VoidAction(string actionId)
        {
            /* Note that no related fields are loaded */
            IQueryable <Action> queryableAction = _actionService.GetAction(actionId);
            Action     action     = queryableAction.First();
            Evaluation evaluation = queryableAction.Select(q => q.Question.Evaluation).First();

            Role[] canBePerformedBy = { Role.Facilitator };
            AssertCanPerformMutation(evaluation, canBePerformedBy);

            _actionService.SetVoid(action, true);
            return(action);
        }
Ejemplo n.º 12
0
        public void GetExists()
        {
            ActionService      actionService      = new ActionService(_context);
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().First();
            QuestionService    questionService    = new QuestionService(_context);
            Question           question           = questionService.GetAll().First();

            Action actionCreate = actionService.Create(participant, participant, "description", DateTimeOffset.UtcNow, "title", Priority.High, question);

            Action actionGet = actionService.GetAction(actionCreate.Id).First();

            Assert.Equal(actionCreate, actionGet);
        }
Ejemplo n.º 13
0
        public void GetExists()
        {
            NoteService        noteService        = new NoteService(fixture.context);
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            Note NoteCreate = noteService.Create(participant, "text", action);

            Note NoteGet = noteService.GetNote(NoteCreate.Id);

            Assert.Equal(NoteCreate, NoteGet);
        }
Ejemplo n.º 14
0
        public VoidActionMutation(DatabaseFixture fixture) : base(fixture)
        {
            _evaluation  = CreateEvaluation();
            _facilitator = _evaluation.Participants.First();
            _authService.LoginUser(_facilitator);

            _organizationLead = CreateParticipant(_evaluation, role: Role.OrganizationLead);
            _participant      = CreateParticipant(_evaluation, role: Role.Participant);
            _question         = GetFirstQuestion(_evaluation);
            _action           = CreateAction(
                questionId: _question.Id,
                assignedToId: Randomize.Value <Participant>(_evaluation.Participants).Id
                );
        }
Ejemplo n.º 15
0
        public void GetExists()
        {
            ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context);
            ParticipantService   participantService   = new ParticipantService(fixture.context);
            Participant          participant          = participantService.GetAll().First();
            ActionService        actionService        = new ActionService(fixture.context);
            Action action = actionService.GetAll().First();

            ClosingRemark ClosingRemarkCreate = closingRemarkService.Create(participant, "text", action);

            ClosingRemark ClosingRemarkGet = closingRemarkService.GetClosingRemark(ClosingRemarkCreate.Id);

            Assert.Equal(ClosingRemarkCreate, ClosingRemarkGet);
        }
Ejemplo n.º 16
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            NoteService noteService = new NoteService(fixture.context);
            int         nNoteBefore = noteService.GetAll().Count();

            noteService.Create(participant, "text", action);
            int nNotesAfter = noteService.GetAll().Count();

            Assert.Equal(nNoteBefore + 1, nNotesAfter);
        }
Ejemplo n.º 17
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context);
            int nClosingRemarksBefore = closingRemarkService.GetAll().Count();

            closingRemarkService.Create(participant, "text", action);
            int nClosingRemarksAfter = closingRemarkService.GetAll().Count();

            Assert.Equal(nClosingRemarksBefore + 1, nClosingRemarksAfter);
        }
Ejemplo n.º 18
0
        public void EditNote()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();

            ActionService actionService = new ActionService(fixture.context);
            Action        action        = actionService.GetAll().First();

            NoteService noteService = new NoteService(fixture.context);
            string      initialText = "initial text";
            Note        note        = noteService.Create(participant, initialText, action);
            string      noteId      = note.Id;

            string newText = "new text";

            noteService.EditNote(note, newText);

            Note resultingNote = noteService.GetNote(noteId);

            Assert.Equal(newText, resultingNote.Text);
        }
Ejemplo n.º 19
0
        public void EditAction()
        {
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().First();

            QuestionService questionService = new QuestionService(_context);
            Question        question        = questionService.GetAll().First();

            ActionService actionService      = new ActionService(_context);
            string        initialDescription = "initial description";
            Action        action             = actionService.Create(participant, participant, initialDescription, DateTimeOffset.UtcNow, "title", Priority.Medium, question);
            string        actionId           = action.Id;

            string newDescription = "new description";

            actionService.EditAction(action, participant, newDescription, DateTimeOffset.UtcNow, "title", false, false, Priority.High);

            Action resultingAction = actionService.GetAction(actionId).First();

            Assert.Equal(newDescription, resultingAction.Description);
        }
Ejemplo n.º 20
0
        public Note Create(
            Participant createdBy,
            string text,
            Action action
            )
        {
            DateTimeOffset createDate = DateTimeOffset.UtcNow;

            Note newNote = new Note
            {
                CreateDate = createDate,
                Text       = text,
                CreatedBy  = createdBy,
                Action     = action
            };

            _context.Notes.Add(newNote);

            _context.SaveChanges();
            return(newNote);
        }
Ejemplo n.º 21
0
        public ClosingRemark Create(
            Participant createdBy,
            string text,
            Action action
            )
        {
            DateTimeOffset createDate = DateTimeOffset.UtcNow;

            ClosingRemark newClosingRemark = new ClosingRemark
            {
                CreateDate = createDate,
                Text       = text,
                CreatedBy  = createdBy,
                Action     = action
            };

            _context.ClosingRemarks.Add(newClosingRemark);

            _context.SaveChanges();
            return(newClosingRemark);
        }