Ejemplo n.º 1
0
        public Task <InvokeResult <ServiceTicket> > AddTicketNoteAsync(string id, [FromBody] ServiceTicketNote note)
        {
            note.Id        = Guid.NewGuid().ToId();
            note.AddedBy   = UserEntityHeader;
            note.DateStamp = DateTime.UtcNow.ToJSONString();

            return(_mgr.AddTicketNoteAsync(id, note, OrgEntityHeader, UserEntityHeader));
        }
        public async Task <InvokeResult <ServiceTicket> > AddTicketNoteAsync(string ticketId, ServiceTicketNote ticketNote, EntityHeader org, EntityHeader user)
        {
            if (string.IsNullOrEmpty(ticketId))
            {
                throw new ArgumentNullException(nameof(ticketId));
            }
            if (org == null)
            {
                throw new ArgumentNullException(nameof(org));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (ticketNote == null)
            {
                throw new ArgumentNullException(nameof(ticketNote));
            }

            var ticket = await _repo.GetServiceTicketAsync(ticketId);

            await AuthorizeAsync(ticket, AuthorizeResult.AuthorizeActions.Update, user, org, "AddNote");

            ValidationCheck(ticketNote, Actions.Create);

            ticket.Notes.Add(ticketNote);
            ticket.LastUpdatedBy   = user;
            ticket.LastUpdatedDate = ticketNote.DateStamp;
            await _repo.UpdateServiceTicketAsync(ticket);

            return(InvokeResult <ServiceTicket> .Create(ticket));
        }