Beispiel #1
0
        public async Task <GenericResponse> UpdateTicket(TicketUpdateVM model)
        {
            GenericResponse res = null;

            try
            {
                string _requestType   = Enum.GetName(typeof(RequestType), Convert.ToInt32(model.ticketDetail.responseObject.requestType));
                string _priorityLevel = Enum.GetName(typeof(PriorityLevel), Convert.ToInt32(model.ticketDetail.responseObject.priorityLevel));
                model.ticketDetail.responseObject.requestType   = _requestType;
                model.ticketDetail.responseObject.priorityLevel = _priorityLevel;
                var         endpoint     = _configuration.GetSection("API").GetSection("updateticket").Value;
                HttpClient  client       = _apiHelper.InitializeClient();
                var         json         = JsonConvert.SerializeObject(model.ticketDetail);
                HttpContent updateTicket = new StringContent(json, Encoding.UTF8, "application/json");
                var         response     = await client.PostAsync(endpoint, updateTicket);

                if (response.IsSuccessStatusCode)
                {
                    res = JsonConvert.DeserializeObject <GenericResponse>(await response.Content.ReadAsStringAsync());
                }
                else
                {
                    res = JsonConvert.DeserializeObject <GenericResponse>(await response.Content.ReadAsStringAsync());
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(res);
        }
Beispiel #2
0
        public async Task <IActionResult> UpdateTicket(string ticketId)
        {
            TicketUpdateVM ticketUpdateVM = new TicketUpdateVM();
            bool           _checkSession  = CheckSession();

            if (_checkSession)
            {
                return(RedirectToAction(nameof(Logout)));
            }
            try
            {
                ticketUpdateVM.ticketDetail = await _ticket.GetTicket(ticketId);

                ticketUpdateVM.clients = await _client.GetAllClients();
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(View(ticketUpdateVM));
        }
Beispiel #3
0
        public async Task <IActionResult> UpdateTicket(TicketUpdateVM model)
        {
            bool _checkSession = CheckSession();

            if (_checkSession)
            {
                return(RedirectToAction(nameof(Logout)));
            }
            try
            {
                if (ModelState.IsValid)
                {
                    var result = await _ticket.UpdateTicket(model);

                    if (result != null)
                    {
                        _logger.LogInformation($"ticket updated successfully....");
                        TempData["msg"] = $"Ticket updated successfully";
                    }
                    else
                    {
                        _logger.LogInformation($"could not update ticket....");
                        TempData["msg"] = $"Internal Server Error";
                        return(RedirectToAction(nameof(UpdateTicket), new { ticketId = model.ticketDetail.responseObject.ticketId }));
                    }
                }
                else
                {
                    _logger.LogInformation($"Invalid model state....", model.clients);
                    ViewBag.msg = $"Please fill out all fields";
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"{ex?.InnerException?.InnerException?.Message}");
            }
            return(RedirectToAction(nameof(Index)));
        }