Esempio n. 1
0
        public bool UpdateTicket(UpdateTicketRequest data)
        {
            if (data == null)
            {
                return(false);
            }

            var ticket = _db.Tickets.Where(a => a.Id == data.Id).FirstOrDefault();

            if (ticket == null)
            {
                return(false);
            }
            if (data.Query != null)
            {
                ticket.Query = data.Query;
            }
            if (data.Status != null)
            {
                ticket.Status = data.Status;
            }
            if (data.ContactId != '\0')
            {
                ticket.ContactId = data.ContactId;
            }
            _db.SaveChanges();
            return(true);
        }
 public bool UpdateTicket(UpdateTicketRequest request)
 {
     if (request != null)
     {
         var ticket = _db.Tickets.Where(a => a.Id == request.Id).FirstOrDefault();
         if (ticket != null)
         {
             ticket.Title        = string.IsNullOrEmpty(request.Title) ? ticket.Title : request.Title;
             ticket.Description  = string.IsNullOrEmpty(request.Description) ? ticket.Description : request.Description;
             ticket.LastModified = DateTime.Now;
             _db.SaveChanges();
             Logs logs = new Logs
             {
                 Title        = string.IsNullOrEmpty(request.Title) ? ticket.Title : request.Title,
                 Description  = string.IsNullOrEmpty(request.Description) ? ticket.Description : request.Description,
                 LastModified = DateTime.Now,
                 ticketId     = request.Id,
                 registerId   = ticket.registerId,
             };
             _db.Logs.Add(logs);
             _db.SaveChanges();
             return(true);
         }
     }
     return(false);
 }
 public IActionResult UpdateTicket(UpdateTicketRequest request)
 {
     if (request == null)
     {
         return(BadRequest(new { message = "Please check your input" }));
     }
     return(Ok(ticketRepository.UpdateTicket(request)));
 }
 /// <summary>
 /// Create a new ticket in Freshdesk.
 ///
 /// c.f. https://developers.freshdesk.com/api/#create_ticket
 /// </summary>
 ///
 /// <param name="ticketId">
 /// The unique identifier for the ticket to be updated.
 /// </param>
 ///
 /// <param name="updateTicketRequest">
 /// Describes the values of all the fields in the new ticket.
 /// </param>
 ///
 /// <param name="cancellationToken"></param>
 ///
 /// <returns>
 /// The updated ticket with all the new values as seen by the API.
 /// </returns>
 public async Task <Ticket> UpdateTicketAsync(
     long ticketId,
     UpdateTicketRequest updateTicketRequest,
     CancellationToken cancellationToken = default)
 {
     return(await _freshdeskClient
            .ApiOperationAsync <Ticket, UpdateTicketRequest>(HttpMethod.Put, $"/api/v2/tickets/{ticketId}", updateTicketRequest, cancellationToken : cancellationToken)
            .ConfigureAwait(false));
 }
        public IActionResult update(Guid id, UpdateTicketRequest req)
        {
            var userId = HttpContext.User.Claims.Single(x => x.Type == "Id").Value;

            var res = _ticketService.Update(id, Guid.Parse(userId), req);

            if (!res.Success)
            {
                return(BadRequest(res));
            }
            return(Ok(res));
        }
Esempio n. 6
0
        static void UpdateTicket(MagentoService service, string siteUrl, string token, int ticketId)
        {
            var updateTicketRequest = new UpdateTicketRequest()
            {
                ticket_id        = ticketId.ToString(),
                status           = "read",
                type             = "dispute",
                item_id          = "listing124",
                subject          = "listing",
                updated_by_id    = "daolam",
                last_modified_at = DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"),
                note             = "updated note",
            };
            var result = service.UpdateTicket(siteUrl, token, updateTicketRequest);

            if (result.HasError)
            {
                Console.WriteLine("UpdateTicket " + result.Error);
            }
            else
            {
                Console.WriteLine("UpdateTicket " + result.Result.ToString());
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> Update([FromRoute] Guid ticketId, [FromBody] UpdateTicketRequest request)
        {
            var newAssignee = await _userService.GetUserByUserIdAsync(request.AssigneeId);

            var ticket = await _ticketService.GetByIdAsync(ticketId);

            ticket.Title       = request.Title;
            ticket.Description = request.Description;
            ticket.Priority    = request.Priority;
            ticket.Status      = request.Status;
            ticket.UpdatedAt   = DateTime.UtcNow;
            ticket.AssigneeId  = newAssignee?.Id;

            var updated = await _ticketService.UpdateAsync(ticket);

            var ticketDto = _ticketToDtoConverter.Convert(ticket);

            if (updated)
            {
                return(Ok(ticketDto));
            }

            return(NotFound());
        }
        public async Task <IActionResult> UpdateTicketById(int id, [FromBody] UpdateTicketRequest updateTicketRequest)
        {
            var ticket = await _tService.UpdateTicketByIdAsync(id, updateTicketRequest);

            return(Ok(ticket));
        }
        public async Task <IActionResult> CreateTicket([FromBody] UpdateTicketRequest updateTicketRequest)
        {
            var ticket = await _tService.CreateTicketAsync(updateTicketRequest);

            return(Ok(new { status = 200, data = ticket, message = "You bought a ticket!" }));
        }
Esempio n. 10
0
        public MagentoServiceResponse <bool> UpdateTicket(string siteUrl, string token, UpdateTicketRequest updateTicketRequest)
        {
            var client          = CreateRestClient(siteUrl, token);
            var serviceResponse = new MagentoServiceResponse <bool>();
            var request         = CreateRequest("/rest/aheadworks/helpdesk/updateticket", Method.POST);

            request.AddBody(updateTicketRequest);

            try
            {
                var response = client.Execute(request);
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var content = SimpleJson.DeserializeObject <JsonArray>(response.Content);
                    if (content == null)
                    {
                        serviceResponse.Error = "Can not deserialize content";
                    }
                    else
                    {
                        serviceResponse.Result = (bool)content[0];
                    }
                }
                else
                {
                    serviceResponse.Error = response.Content;
                }
            }
            catch (Exception ex)
            {
                serviceResponse.Error = ex.Message;
            }

            return(serviceResponse);
        }
Esempio n. 11
0
        public UpdateResponse <TicketDTO> Update(Guid id, Guid userId, UpdateTicketRequest req)
        {
            var res = new UpdateResponse <TicketDTO>();

            var type = req.Type.ConvertToTicketType();

            var ticket = _ticketRepository.FindById(id);

            if (ticket == null)
            {
                return((UpdateResponse <TicketDTO>)res.ReturnErrorResponseWith("Ticket not found"));
            }

            if (ticket.Project.ProjectUsersReq.Where(
                    pur => pur.UserAssigned.Id.Equals(userId) ||
                    pur.Sender.Id.Equals(userId)).ToList().Count <= 0)
            {
                return((UpdateResponse <TicketDTO>)
                       res.ReturnErrorResponseWith("You can cnahge only tickets on projects that you are working on!"));
            }

            var user = _userRepository.FindById(userId);

            if (user == null)
            {
                return((UpdateResponse <TicketDTO>)
                       res.ReturnErrorResponseWith("User not found"));
            }

            var status = _ticketStatusRepository.FindById(req.StatusId);

            if (status == null)
            {
                return((UpdateResponse <TicketDTO>)
                       res.ReturnErrorResponseWith("Status not found"));
            }

            var histories = _ticketDomainService
                            .GetHistoriesFor(ticket,
                                             user,
                                             req.Title,
                                             req.Description,
                                             req.Deadline,
                                             type,
                                             status);


            if (type != TicketType.UNDEFINED)
            {
                ticket.Type = type;
            }


            ticket.Title       = req.Title;
            ticket.Description = req.Description;
            ticket.Deadline    = req.Deadline;
            ticket.Status      = status;

            ticket.Validate();

            if (ticket.GetBrokenRules().Count > 0)
            {
                return((UpdateResponse <TicketDTO>)
                       res.ReturnErrorResponseWithMultiple(ticket.GetBrokenRules()));
            }

            ticket.Updated = DateTime.Now;

            foreach (var history in histories)
            {
                _ticketHistoryRepository.Save(history);
            }

            _ticketRepository.Update(ticket);

            try
            {
                _uow.Commit();
            }
            catch (Exception ex)
            {
                return((UpdateResponse <TicketDTO>)
                       res.ReturnErrorResponseWith(ex.Message));
            }

            res.EntityDTO = _mapper.Map <Ticket, TicketDTO>(ticket);
            res.Success   = true;

            return(res);
        }
Esempio n. 12
0
 public IActionResult UpdateUser(UpdateTicketRequest data)
 {
     // IUsersRepo repo = new UsersRepo();
     return(Ok(repo.UpdateTicket(data)));
 }