private DateTime?GetDateValue(ApiTicketsIssued value)
        {
            if (string.IsNullOrEmpty(value.Paid))
            {
                return(null);
            }
            else if (value.Paid.Equals("Paid"))
            {
                return(DateTime.Now);
            }

            return(DateTime.Parse(value.Paid));
        }
Esempio n. 2
0
        static void Main(String[] args)
        {
            FireBaseDbService dbservice = new FireBaseDbService();

            dbservice.Init();
            ApiTicketsIssued ticketsIssued = new ApiTicketsIssued()
            {
                TicketId         = 0001,
                Agent            = "SHAN",
                Category         = "VIP",
                TicketStatusCode = "SPAD",
                Zone             = "VIP",
                SoldTo           = "Shasinda",
                TicketNumber     = "VIP001",
                Paid             = "22/06/2022",
                Notes            = "Great Guy, Free tickets for future okm events"
            };

            dbservice.writeToDb(ticketsIssued);
        }
        // POST: api/TicketB
        public HttpResponseMessage Post(ApiTicketsIssued value)
        {
            var ticketManagerResponse = ticketManagerService.UpdateTicket(new TicketsIssued
            {
                AgentCode        = value.Agent,
                TicketNumber     = value.TicketNumber,
                TicketStatusCode = value.TicketStatusCode,
                Category         = value.Category,
                SoldTo           = value.SoldTo,
                Zone             = value.Zone,
                Notes            = value.Notes,
                TicketId         = value.TicketId,
                Paid             = GetDateValue(value)
            });

            if (ticketManagerResponse.IsASuccess)
            {
                return(Request.CreateResponse(HttpStatusCode.Created));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, new HttpError(ticketManagerResponse.Errors.First())));
            }
        }
        public void writeToDb(ApiTicketsIssued ticketIssued)
        {
            var setter = client.Set("ticketIssued/" + ticketIssued.TicketId, ticketIssued);

            Console.Write("Succeefully written to db");
        }