public bool CreateTicket(CustomerTicket ticket, CustomerPayment payment, Customer customer) { try { Dictionary <String, Object> extraParamenter = new Dictionary <string, object>(); extraParamenter.Add("ticket", JsonConvert.SerializeObject(ticket)); extraParamenter.Add("payment", JsonConvert.SerializeObject(payment)); Infra.Queue.AzureQueueMessageManager.Enqueue(customer.Id.ToString(), customer.Name, null, Infra.Queue.AzureMessageType.NEW_TRANSACTION, extraParamenter); return(true); } catch (System.Exception ex) { throw ex; } }
public bool CreateQuickTicket(CustomerTicket ticket, CustomerPayment payment, Customer customer) { try { Dictionary<String, Object> extraParamenter = new Dictionary<string, object>(); extraParamenter.Add("ticket", JsonConvert.SerializeObject(ticket)); extraParamenter.Add("payment", JsonConvert.SerializeObject(payment)); Infra.Queue.AzureQueueMessageManager.Enqueue(customer.Id.ToString(), customer.Name, null, Infra.Queue.AzureMessageType.NEW_TRANSACTION_INSTANT_BUY, extraParamenter); return true; } catch (System.Exception ex) { throw ex; } }
public ActionResult Create(CustomerTicket cTicket) { if (ModelState.IsValid) { Customer customer = unitOfWork.CustomerRepository.GetSingleRecord(Int32.Parse(cTicket.Customer)); DailyTicketCount dailyCount = unitOfWork.DailyTicketCountRepository.LatestRecord(); if (cTicket.Ticket.ActionWith.Equals("Relayware", StringComparison.Ordinal)) { customer.NumOpenTicketsRelayware += 1; dailyCount.TotalOpenTicketsRelayware += 1; } else if (cTicket.Ticket.ActionWith.Equals("Customer", StringComparison.Ordinal)) { customer.NumOpenTicketsCust += 1; dailyCount.TotalOpenTicketsCust += 1; } if (cTicket.Ticket.Status.Equals("Open", StringComparison.Ordinal)) { customer.NumOpenTickets += 1; dailyCount.TotalOpenedTicket += 1; } else if (cTicket.Ticket.Status.Equals("Closed", StringComparison.Ordinal)) { customer.NumClosedTickets += 1; dailyCount.TotalClosedTickets += 1; } unitOfWork.CustomerRepository.UpdateRecord(customer); cTicket.Ticket.Customer = customer; unitOfWork.TicketRepository.AddRecord(cTicket.Ticket); unitOfWork.DailyTicketCountRepository.UpdateRecord(dailyCount); unitOfWork.SaveChanges(); return(RedirectToAction("Index", "DailyTicketCounts", null)); } return(View()); }
public HttpResponseMessage CreateDalalTicket(CustomerTicket ticket) { try { var result = Manager.CreateDalalTicket(ticket, ticket.who); return(OkResponse <CustomerTicket>(result)); } catch (Exception ex) { if (ex.Message.StartsWith("contact With Id")) { string message = string.IsNullOrEmpty(ex.Message) ? "Contact Not Found" : ex.Message; return(NotFoundResponse("Contact Not Found", message)); } else { return(NotFoundResponse("Error in create dalal ticket", ex.Message)); } } }
private void ProcessQuickTransaction(AzureMessage azureMessage) { var jsonTicket = (string)azureMessage.ExtraData["ticket"]; var jsonPayment = (string)azureMessage.ExtraData["payment"]; CustomerTicket ticket = JsonConvert.DeserializeObject <CustomerTicket>(jsonTicket); CustomerPayment payment = JsonConvert.DeserializeObject <CustomerPayment>(jsonPayment); Customer customer = this.customerService.GetCustomerById(new Guid(azureMessage.SenderUserId)); ticket.IdEvent = ticket.Event.Id; ticket.IdCustomer = customer.Id; if (MundiPaggProxy.ProcessPayment(ticket, payment.InstantBuy, payment.SecurityCode)) { var ticketUpdate = this.customerTicketService.GetTicketById(ticket.Id); ticketUpdate.Status = ticket.Status; this.customerTicketService.Update(ticketUpdate); this.SendEmail(ticket, customer); } }
public object PostTicket(TicketModel loginModel) { CustomerTicket customerticket = new CustomerTicket { CustomerId = Convert.ToInt32(loginModel.id), Content = loginModel.content, CreatedDate = DateTime.Now, Title = "Title" }; db.CustomerTicket.Add(customerticket); db.SaveChanges(); //if (LoginManager.Login(loginModel.username, loginModel.password, out errorMessage)) //{ // return new { Result = true, User = LoginManager.CurrentUser.Transform() }; //} //else //{ return(new { model = customerticket }); // } }
private void ProcessTransaction(AzureMessage azureMessage) { var jsonPayment = (string)azureMessage.ExtraData["payment"]; var jsonTicket = (string)azureMessage.ExtraData["ticket"]; CustomerPayment payment = JsonConvert.DeserializeObject <CustomerPayment>(jsonPayment); CustomerTicket ticket = JsonConvert.DeserializeObject <CustomerTicket>(jsonTicket); Customer customer = this.customerService.GetCustomerById(new Guid(azureMessage.SenderUserId)); ticket.IdEvent = ticket.Event.Id; ticket.IdCustomer = customer.Id; Guid instantBuy; if (MundiPaggProxy.ProcessPayment(ticket, payment, out instantBuy)) { var ticketUpdate = this.customerTicketService.GetTicketById(ticket.Id); ticketUpdate.Status = ticket.Status; this.customerTicketService.Update(ticketUpdate); this.SendEmail(ticket, customer); if (payment.KeepSave) { if (!customer.PaymentTokenizer.Any(x => x.Token == instantBuy.ToString())) { var customerToken = new CustomerPaymentTokenizer() { Id = Guid.NewGuid(), IdCustomer = customer.Id, SecurityCode = payment.SecurityCode, Token = instantBuy.ToString() }; customer.PaymentTokenizer.Add(customerToken); this.customerService.Update(customer); } } } }
public ApiResult <CustomerTicket> SaveQuick(string customerId, CustomerTicket ticket, CustomerPayment payment, Event eventTicket) { try { var customer = this.customerService.GetCustomerById(Guid.Parse(customerId)); ticket.Event = eventTicket; var result = this.customerService.CreateQuickTicket(ticket, payment, customer); return(new ApiResult <CustomerTicket>() { Result = result, Data = ticket, }); } catch (System.Exception ex) { return(new ApiResult <CustomerTicket>() { Result = false, Data = null, ErrorMessage = ex.Message }); } }
public bool CreateQuickTicket(CustomerTicket ticket, CustomerPayment payment, Customer customer) { try { Log.Info($"Criando o ticket do cliente com o id {customer.Id}"); ticket.Status = Enum.StatusEnum.Pending; ticket.Id = Guid.NewGuid(); var result = this.customerTicketService.CreateQuickTicket(ticket, payment, customer); if (result) { customer.Tickets.Add(ticket); this.customerRepository.Update(customer); } return result; } catch (Exception ex) { Log.Error(ex.Message, ex); throw; } finally { Log.Info($"Finalizando a criação do ticket do evento para o cliente {customer.Id}"); } }
internal static bool ProcessPayment(CustomerTicket ticket, CustomerPayment payment, out Guid instantBuy) { var amountTransaction = (long)(ticket.Quantity * ticket.Event.Price); var expiration = payment.Expiration.Split('/'); var expMonth = Convert.ToInt32(expiration.FirstOrDefault()); var expYear = Convert.ToInt32(expiration.LastOrDefault()); instantBuy = Guid.Empty; try { Log.Info($"Create transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); // Cria a transação. var transaction = new CreditCardTransaction() { AmountInCents = amountTransaction, CreditCard = new CreditCard() { CreditCardBrand = ConvertCreditCardBrand(payment), CreditCardNumber = payment.CreditCardNumber, ExpMonth = expMonth, ExpYear = expYear, HolderName = payment.HolderName, SecurityCode = payment.SecurityCode }, }; // Cria requisição. var createSaleRequest = new CreateSaleRequest() { // Adiciona a transação na requisição. CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction }), }; Log.Info($"Make request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); var serviceClient = new GatewayServiceClient(merchantKey, hostUri); // Autoriza a transação e recebe a resposta do gateway. var httpResponse = serviceClient.Sale.Create(createSaleRequest); Log.Info($"Request Status for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer} with status {httpResponse.HttpStatusCode}"); if (httpResponse.Response.CreditCardTransactionResultCollection != null) { var transactionStatus = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus; Log.Info($"Transaction Status for ticket {ticket.Id} with status {transactionStatus.ToString()}"); if (transactionStatus == CreditCardTransactionStatusEnum.NotAuthorized) { ticket.Status = Enum.StatusEnum.NotAuthorized; } if (transactionStatus == CreditCardTransactionStatusEnum.Captured) { ticket.Status = Enum.StatusEnum.Authorized; } if (payment.KeepSave) { instantBuy = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCard.InstantBuyKey; } return(true); } return(false); } catch (System.Exception ex) { Log.Error($"Request Error for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}", ex); throw ex; } finally { Log.Info($"End Request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); } }
internal static bool ProcessPayment(CustomerTicket ticket, Guid instantBuy, string securityCode) { var amountTransaction = (long)(ticket.Quantity * ticket.Event.Price); try { Log.Info($"Create transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); // Cria a transação. var transaction = new CreditCardTransaction() { AmountInCents = amountTransaction, CreditCard = new CreditCard() { InstantBuyKey = instantBuy, SecurityCode = securityCode }, }; // Cria requisição. var createSaleRequest = new CreateSaleRequest() { // Adiciona a transação na requisição. CreditCardTransactionCollection = new Collection<CreditCardTransaction>(new CreditCardTransaction[] { transaction }), }; Log.Info($"Make request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); var serviceClient = new GatewayServiceClient(merchantKey, hostUri); // Autoriza a transação e recebe a resposta do gateway. var httpResponse = serviceClient.Sale.Create(createSaleRequest); Log.Info($"Request Status for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer} with status {httpResponse.HttpStatusCode}"); if (httpResponse.Response.CreditCardTransactionResultCollection != null) { var transactionStatus = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus; Log.Info($"Transaction Status for ticket {ticket.Id} with status {transactionStatus.ToString()}"); if (transactionStatus == CreditCardTransactionStatusEnum.NotAuthorized) ticket.Status = Enum.StatusEnum.NotAuthorized; if (transactionStatus == CreditCardTransactionStatusEnum.Captured) ticket.Status = Enum.StatusEnum.Authorized; return true; } return false; } catch (System.Exception ex) { Log.Error($"Request Error for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}", ex); throw ex; } finally { Log.Info($"End Request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); } }
internal static bool ProcessPayment(CustomerTicket ticket, CustomerPayment payment, out Guid instantBuy) { var amountTransaction = (long)(ticket.Quantity * ticket.Event.Price); var expiration = payment.Expiration.Split('/'); var expMonth = Convert.ToInt32(expiration.FirstOrDefault()); var expYear = Convert.ToInt32(expiration.LastOrDefault()); instantBuy = Guid.Empty; try { Log.Info($"Create transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); // Cria a transação. var transaction = new CreditCardTransaction() { AmountInCents = amountTransaction, CreditCard = new CreditCard() { CreditCardBrand = ConvertCreditCardBrand(payment), CreditCardNumber = payment.CreditCardNumber, ExpMonth = expMonth, ExpYear = expYear, HolderName = payment.HolderName, SecurityCode = payment.SecurityCode }, }; // Cria requisição. var createSaleRequest = new CreateSaleRequest() { // Adiciona a transação na requisição. CreditCardTransactionCollection = new Collection<CreditCardTransaction>(new CreditCardTransaction[] { transaction }), }; Log.Info($"Make request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); var serviceClient = new GatewayServiceClient(merchantKey, hostUri); // Autoriza a transação e recebe a resposta do gateway. var httpResponse = serviceClient.Sale.Create(createSaleRequest); Log.Info($"Request Status for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer} with status {httpResponse.HttpStatusCode}"); if (httpResponse.Response.CreditCardTransactionResultCollection != null) { var transactionStatus = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus; Log.Info($"Transaction Status for ticket {ticket.Id} with status {transactionStatus.ToString()}"); if (transactionStatus == CreditCardTransactionStatusEnum.NotAuthorized) ticket.Status = Enum.StatusEnum.NotAuthorized; if (transactionStatus == CreditCardTransactionStatusEnum.Captured) ticket.Status = Enum.StatusEnum.Authorized; if (payment.KeepSave) instantBuy = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCard.InstantBuyKey; return true; } return false; } catch (System.Exception ex) { Log.Error($"Request Error for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}", ex); throw ex; } finally { Log.Info($"End Request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); } }
public ActionResult Book(int id, int type) { Ticket ticket = db.Tickets.Find(id); customer custobj = db.customers.Find(Convert.ToInt32(Session["UserID"])); CustomerTicket custticket = new CustomerTicket(); custticket.CustomerID = custobj.ID; custticket.TicketID = ticket.L_ID; custticket.CreatedDate = DateTime.Today; db.CustomerTickets.Add(custticket); db.SaveChanges(); if (custobj != null) { EMail omail = new EMail(); try { string sub = ""; string Fare = ""; string UN = ""; string Start = ""; string Destination = ""; string LN = ""; string DT = ""; string Time = ""; if (type == 1) { sub = "Deck Fare"; Fare += ticket.Fare_Deck; UN += custobj.user_name; Start += ticket.Start; Destination += ticket.Destination; DT += ticket.Dept_Time; LN += ticket.L_Name; } if (type == 3) { sub = "Cabin Fare"; Fare += ticket.Fare_Cabin; UN += custobj.user_name; Start += ticket.Start; Destination += ticket.Destination; DT += ticket.Dept_Time; LN += ticket.L_Name; } if (type == 2) { sub = "First Class Fare"; Fare += ticket.Fare_1st_Class; UN += custobj.user_name; Start += ticket.Start; Destination += ticket.Destination; DT += ticket.Dept_Time; LN += ticket.L_Name; } omail.SendMail("Email", custobj.email, new string[] { sub, UN, Start, Destination, DT, LN, Fare }); } catch (Exception) { throw; } return(View(ticket)); } if (Session["UserID"] != null) { ViewBag.User = "******"; ViewBag.UserName = Session["UserName"]; } return(View(ticket)); }
public void Update(CustomerTicket ticket) { this.customerTicketRepository.Update(ticket); }
internal static bool ProcessPayment(CustomerTicket ticket, Guid instantBuy, string securityCode) { var amountTransaction = (long)(ticket.Quantity * ticket.Event.Price); try { Log.Info($"Create transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); // Cria a transação. var transaction = new CreditCardTransaction() { AmountInCents = amountTransaction, CreditCard = new CreditCard() { InstantBuyKey = instantBuy, SecurityCode = securityCode }, }; // Cria requisição. var createSaleRequest = new CreateSaleRequest() { // Adiciona a transação na requisição. CreditCardTransactionCollection = new Collection <CreditCardTransaction>(new CreditCardTransaction[] { transaction }), }; Log.Info($"Make request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); var serviceClient = new GatewayServiceClient(merchantKey, hostUri); // Autoriza a transação e recebe a resposta do gateway. var httpResponse = serviceClient.Sale.Create(createSaleRequest); Log.Info($"Request Status for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer} with status {httpResponse.HttpStatusCode}"); if (httpResponse.Response.CreditCardTransactionResultCollection != null) { var transactionStatus = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus; Log.Info($"Transaction Status for ticket {ticket.Id} with status {transactionStatus.ToString()}"); if (transactionStatus == CreditCardTransactionStatusEnum.NotAuthorized) { ticket.Status = Enum.StatusEnum.NotAuthorized; } if (transactionStatus == CreditCardTransactionStatusEnum.Captured) { ticket.Status = Enum.StatusEnum.Authorized; } return(true); } return(false); } catch (System.Exception ex) { Log.Error($"Request Error for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}", ex); throw ex; } finally { Log.Info($"End Request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}"); } }
public HttpResponseMessage CreateIndividualTicket(CustomerTicket ticket, Who who = Who.Web) { var result = Manager.CreateIndividualTicket(ticket, who); return(OkResponse <CustomerTicket>(result)); }
public void Update(CustomerTicket ticket) { this.customerTicketRepository.Update(ticket); }
private void SendEmail(CustomerTicket ticket, Customer customer) { var model = new { Name = customer.Name, EventName = ticket.Event.Name, Status = ticket.Status.ToString(), }; Stream stream = GetStreamEmail(this.NewTransactionUpdate); string emailBody = Infra.Utils.EmailUtils.TransformTemplate(stream, model); Infra.Utils.EmailUtils.SendEmail(customer.Email, emailBody, Infra.Utils.EmailUtils.EmaiSubject.NEW_TRANSACTION_UPDATE); }