public IActionResult UpdateOrder([FromBodyAttribute] TicketOrderUpdate Request) { if (!ModelState.IsValid || Request.OrderId == 0 || string.IsNullOrEmpty(Request.status)) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "1000", ResponseMessage = "failed", Status = "Error in Api while Update in OrderTicket ", ResponseResult = "Request is Invalid" })); } try { ITicketStatusRepository _status = new TicketStatusRepository(_applicationDbContext); var Status = _status.FindBy(x => x.fullName == Request.status).FirstOrDefault().Id; TicketOrders order = _order.FindBy(x => x.Id == Request.OrderId).SingleOrDefault(); order.ticketStatus = Convert.ToInt32(Status); _order.Update(order); _order.Commit(); return(Ok(new Application_ResponseWrapper() { ResponseCode = "0", ResponseMessage = "success", Status = "success", ResponseResult = order })); } catch (Exception e) { return(Ok(new Application_ResponseWrapper() { ResponseCode = "1000", ResponseMessage = "failed", Status = "Error in update", ResponseResult = e })); } }
/// <summary> // This Method will return the details of ticket. /// </summary> /// <param name="ticketOrderId">Id of ticket orders.</param> /// <returns>this will return the ticket details object</returns> public TicketOrderViewModel GetTicketDetail(Int64 ticketOrderId) { if (ticketOrderId <= 0) { return(null); } var ticketOrders = _ticketOrdersRepository.FindBy(x => x.Id == ticketOrderId); var bookedTickets = _bookedTicketsRepository.FindBy(x => x.ticketOrderId == ticketOrderId); if (!ticketOrders.Any() || !bookedTickets.Any()) { return(null); } var ticketStatus = _ticketStatusRepository.FindBy(x => x.Id == ticketOrders.FirstOrDefault().ticketStatus); var insurances = _insuranceRepository.FindBy(x => x.pnrNumber == bookedTickets.FirstOrDefault().pnrNumber); var quotas = _quotaRepository.FindBy(x => x.Id == ticketOrders.FirstOrDefault().quota); var refunds = _ticketCancellationRepository.FindBy(x => x.ticketNumber == bookedTickets.FirstOrDefault().ticketNumber); List <RefundHistoryViewModel> refunded = new List <RefundHistoryViewModel>(); if (refunds.Any()) { foreach (TicketCancellations refund in refunds.ToList()) { var cancelledPassengerDetails = _cancelledTicketPassengersRepository.GetSingle(x => x.ticketId == refund.Id); refunded.Add(new RefundHistoryViewModel { Id = refund.Id, ticketOrderId = ticketOrderId, amount = refund.refundedAmount, date = refund.cancelledDate, cancelledPassenger = _ticketPassengersRepository.GetSingle(x => x.Id == cancelledPassengerDetails.passengerId).name }); } } var ticketOrder = ( from orders in ticketOrders.ToList() join tickets in bookedTickets.ToList() on orders.Id equals tickets.ticketOrderId into ticket from t in ticket.DefaultIfEmpty() join quota in quotas.ToList() on orders.quota equals quota.Id into quota from q in quota.DefaultIfEmpty() select new TicketOrderViewModel { Id = ticketOrderId, pnrNumber = t.pnrNumber, transactionId = orders.irctcTxnNumber, sourceStation = orders.sourceStation, destStation = orders.destStation, trainNumber = orders.trainNumber, trainName = orders.trainName, Class = orders.Class, reserveUpto = orders.reserveUpto, bordingPoint = orders.bordingPoint, journeyDay = orders.journeyDay, journeyMonth = orders.journeyMonth, journeyYear = orders.journeyYear, quota = q == null ? "" : q.shortName, bordingDay = t.bordingDay, bordingMonth = t.bordingMonth, bordingYear = t.bordingYear, ticketStatus = ticketStatus.Any() ? ticketStatus.First().shortName : "", ticketInsurance = insurances.ToList().Any() == true ? insurances.First() : null, paymentGatewayName = orders.pmtGatewayName, ticketFare = t.ticketFare, irctcServiceCharge = t.irctcServiceCharge, pgCharges = t.pgCharges, roCommissionOnPGCharge = t.roCommissionOnPGCharge, oxigenServiceCharge = orders.oxigenServiceCharge, totalFare = t.totalFare, refundHistoryList = refunded.Any() ? refunded : null }).SingleOrDefault(); return(ticketOrder); }