Example #1
0
 //UploadCredit(EventTicket _ticket)
 public string LoadCredits(EventTicket ticket)
 {
     try
     {
         DataContractJsonSerializer ser = new DataContractJsonSerializer(
             typeof(EventTicket));
         MemoryStream mem = new MemoryStream();
         ser.WriteObject(mem, ticket);
         string    data      = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
         WebClient webClient = new WebClient();
         webClient.Headers["Content-type"] = "application/json";
         webClient.Encoding = Encoding.UTF8;
         string response = webClient.UploadString(BASE_URL + "UploadCredit", "PUT", data);
         if (response.ToLower().Contains("true"))
         {
             return("success");
         }
         else
         {
             return("failed");
         }
     }
     catch (Exception)
     {
         return("fail");
     }
 }
Example #2
0
        //Upload User CreditsS
        public bool UploadCredit(EventTicket _ticket)
        {
            using (EventrixDBDataContext db = new EventrixDBDataContext())
            {
                try
                {
                    Ticket_Template toInsert = (from st in db.Ticket_Templates where st.TicketID.Equals(_ticket._TicketID) select st).First();
                    toInsert.Credit = _ticket._Credit;
                    db.SubmitChanges();

                    List <Guest_Ticket> insert = (from st in db.Guest_Tickets where st.ticket_temp_id.Equals(_ticket._TicketID) && st.G_ID.Equals(_ticket._GuestID) select st).ToList();
                    //   toInsert.Credit = _ticket._Credit;
                    foreach (Guest_Ticket gt in insert)
                    {
                        var          query = (from qr in db.Guest_QRCodes where qr.ticket_Id.Equals(gt.ticket_Id) select qr).First();
                        Guest_QRCode GQR   = query;
                        GQR.Credit = _ticket._Credit;
                        db.SubmitChanges();
                    }
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }
Example #3
0
 //purchase ticket
 public int updateTicket(EventTicket _ticket)
 {
     try
     {
         using (EventrixDBDataContext dbd = new EventrixDBDataContext())
         {
             int isAvail = (from st in dbd.Guest_Tickets where st.ticket_temp_id.Equals(_ticket._TicketID) && st.G_ID.Equals(_ticket._GuestID) select st).Count();
             if (isAvail != 0)
             {
                 return(0);    //ticket already exist
             }
             else  //update available tickets
             {
                 Guest_Ticket toInsert = new Guest_Ticket();
                 toInsert.ticket_temp_id = _ticket._TicketID;
                 toInsert.G_ID           = _ticket._GuestID;
                 toInsert.numTicket      = _ticket.numTicket;
                 dbd.Guest_Tickets.InsertOnSubmit(toInsert);
                 dbd.SubmitChanges();
             }
         }
         using (EventrixDBDataContext dbd = new EventrixDBDataContext())
         {
             Guest_Ticket toInsert = (from st in dbd.Guest_Tickets where st.ticket_temp_id.Equals(_ticket._TicketID) && st.G_ID.Equals(_ticket._GuestID) select st).First();
             int          ID       = toInsert.ticket_Id;
             return(ID);
         };
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #4
0
        public async Task <IActionResult> PutEventTicket([FromRoute] Guid id, [FromBody] EventTicket eventTicket)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eventTicket.EventTicketId)
            {
                return(BadRequest());
            }

            _context.Entry(eventTicket).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EventTicketExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public HttpResponseMessage UpdateEventTicket(EventTicket updateRecord)
        {
            try
            {
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

                if (updateRecord == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.BadRequest));
                }

                // Update the EventTicket record in the Azure SQL DB:
                int eventTicketResult = _eventTicketWorker.UpdateCreate(updateRecord);
                if (eventTicketResult > 0)
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }
                // Existed already:
                else if (eventTicketResult == 0)
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }

                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }
        }
        /// <summary>
        /// Takes EventID, checks for tickets and updates the ticket with UserID and PurchaseTime = now
        /// </summary>
        /// <param name="iD">eVENT ID</param>
        internal void BuyTicket(int iD)
        {
            EventTicket ticket = DbInterface.GetActiveTicket(iD);

            ticket.UserID       = LoggedInUser.ID;
            ticket.PurchaseTime = DateTime.Now;
            DbInterface.UpdateTicket(ticket);
        }
        // Updating the UserID and PurchaseTime for a ticket
        internal void UpdateTicket(EventTicket ticket)
        {
            string sqlQ = $"UPDATE EventTicket SET [UserID] = {ticket.UserID}, [PurchaseTime] = '{ticket.PurchaseTime}' WHERE [ID] = {ticket.ID}";

            using (SqlCommand command = new SqlCommand(sqlQ, Connection))
            {
                // 4 rows effected raden
                var x = command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Takes eventID and price and send to Dbinterface to save in DB
        /// </summary>
        /// <param name="iD">Event ID</param>
        /// <param name="price"></param>
        internal void CreateEventTicket(int iD, double price)
        {
            EventTicket newEventTicket = new EventTicket()
            {
                EventID = iD,
                Price   = price,
                Active  = true
            };

            DbInterface.SaveEventTicket(newEventTicket);
        }
Example #9
0
        public async Task <IActionResult> PostEventTicket([FromBody] EventTicket eventTicket)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.EventTickets.Add(eventTicket);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEventTicket", new { id = eventTicket.EventTicketId }, eventTicket));
        }
        private QRCodeImage GenerateCode(EventTicket _ticket, int count, string G_ID, int bridgingID, string EventID)
        {
            string ImageName = "Dummy";
            //store New image to database
            QRCodeImage img    = new QRCodeImage();
            QRCodeImage qrcode = new QRCodeImage();

            img.Name         = ImageName;
            img.ticket_ID    = bridgingID;
            img.EntranceTime = DateTime.Now;
            img.Checked_in   = 0;
            img.Credit       = _ticket._Credit;
            img.Location     = "Dummy";
            FileUploadClient fuc = new FileUploadClient();
            int intQRCodeID      = fuc.saveQRCodeImage(img);

            if (intQRCodeID != 0)
            {
                //create QR Code Image
                string QRCodeCotntent = Convert.ToString(intQRCodeID);
                var    writer         = new BarcodeWriter();
                writer.Format = BarcodeFormat.QR_CODE; //populate code with GuestID
                var    result = writer.Write(QRCodeCotntent);
                string path   = Server.MapPath("~/Events/" + _ticket._EventID + "/QR_Codes/" + bridgingID + "_" + G_ID + "_QRImage.jpg");
                ImageName = bridgingID + "_" + G_ID + "_QRImage.jpg";
                var barcodeBitmap = new Bitmap(result);
                using (MemoryStream memory = new MemoryStream())
                {
                    using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
                    {
                        barcodeBitmap.Save(memory, ImageFormat.Png);
                        byte[] bytes = memory.ToArray();
                        fs.Write(bytes, 0, bytes.Length);
                    }
                }

                //UPdate Last Added QRCode Image
                qrcode.Name         = ImageName;
                qrcode.Location     = path;
                qrcode.EntranceTime = DateTime.Now;

                bool isUpdated = fuc.UpdateQRCode(qrcode, Convert.ToString(intQRCodeID));
                if (isUpdated == true)
                {
                    //Alert is created
                }
            }
            return(qrcode);
        }
        // Saves EventTicket to DB
        internal void SaveEventTicket(EventTicket _eventTicket)
        {
            var eventID = _eventTicket.EventID;
            var price   = _eventTicket.Price;
            var active  = _eventTicket.Active;

            string sqlQ = $"INSERT into EventTicket ([EventID],[Price],[Active]) VALUES ('{eventID}', '{price}','{active}')";


            using (SqlCommand command = new SqlCommand(sqlQ, Connection))
            {
                // 4 rows effected raden
                var x = command.ExecuteNonQuery();
            }
        }
        protected void btnUpdateCredit_Click(object sender, EventArgs e)
        {
            string Guest_ID          = Convert.ToString(Session["ID"]);
            TicketServiceClient tsc  = new TicketServiceClient();
            EventTicket         tick = new EventTicket();

            tick._Credit    = Convert.ToInt32(txtNewCredit.Value);
            tick._StartDate = DateTime.Now;
            tick._EndDate   = DateTime.Now;
            tick._TicketID  = Convert.ToInt32(txt_Ticket_ID.Value);
            tick._GuestID   = Convert.ToInt32(Guest_ID);
            String response = tsc.LoadCredits(tick);

            Response.Redirect("GuestTicketList.aspx?hostID=" + Guest_ID);
        }
        internal static void UpdateTicketsFromEventTicket(EventTicket eventTicket, PaymentContext context)
        {
            // get the list of all Tickets associated with this record
            var tickets = context.Ticket.Where(t => t.EventTicketId == eventTicket.EvenTicketId && t.StateCode == 0);

            // update their amount fields
            foreach (var curTicket in tickets)
            {
                curTicket.AmountNonreceiptable = eventTicket.AmountNonReceiptable ?? 0;
                curTicket.AmountReceipted      = eventTicket.AmountReceipted ?? 0;
                curTicket.SyncDate             = null;
                context.Update(curTicket);
            }

            context.SaveChanges();
        }
Example #14
0
        public EventTicket getRegularTicket(string ID)
        {
            string      json   = null;
            EventTicket ticket = null;

            try
            {
                WebClient webClient = new WebClient();
                json   = webClient.DownloadString(BASE_URL + "getRegularTicket/" + ID);
                ticket = JsonConvert.DeserializeObject <EventTicket>(json);
                return(ticket);
            }
            catch
            {
                return(null);
            }
        }
        internal static List <EventPackage> GetEventPackagesFromEventTicket(EventTicket eventTicket, IPaymentContext context)
        {
            var eventPackages = new List <EventPackage>();

            // get the list of all Tickets associated with this record
            var tickets = context.Ticket.Where(t => t.EventTicketId == eventTicket.EvenTicketId && t.StateCode == 0).ToList();

            // get Event Packages from the Tickets
            foreach (var curTicket in tickets)
            {
                if (curTicket.EventPackageId.HasValue)
                {
                    var curEventPackages =
                        context.EventPackage.Where(e => e.EventPackageId == curTicket.EventPackageId && e.StateCode == 0).Distinct().ToList();
                    eventPackages.AddRange(curEventPackages);
                }
            }
            return(eventPackages);
        }
Example #16
0
        public string UpdateTiket(EventTicket _ticket)
        {
            using (EventrixDBDataContext dbd = new EventrixDBDataContext())
            {
                try
                {
                    int isAvail = (from st in dbd.Ticket_Templates where st.eventid.Equals(_ticket._EventID) && st.Type.Equals(_ticket._Type) select st).Count();
                    if (isAvail == 0)
                    {
                        Ticket_Template toInsert = new Ticket_Template();
                        toInsert.Type         = _ticket._Type;
                        toInsert.Credit       = _ticket._Credit;
                        toInsert.Price        = _ticket._Price;
                        toInsert.RefundPolicy = _ticket._Refund;
                        toInsert.StartDate    = _ticket._StartDate;
                        toInsert.EndDate      = _ticket._EndDate;
                        toInsert.eventid      = _ticket._EventID;
                        dbd.Ticket_Templates.InsertOnSubmit(toInsert);
                        dbd.SubmitChanges();
                        return("success");
                    }
                    else  //update available tickets
                    {
                        Ticket_Template toInsert = (from st in dbd.Ticket_Templates where st.eventid.Equals(_ticket._EventID) && st.Type.Equals(_ticket._Type) select st).First();

                        toInsert.Type         = _ticket._Type;
                        toInsert.Credit       = _ticket._Credit;
                        toInsert.Price        = _ticket._Price;
                        toInsert.RefundPolicy = _ticket._Refund;
                        toInsert.StartDate    = _ticket._StartDate;
                        toInsert.EndDate      = _ticket._EndDate;
                        toInsert.eventid      = _ticket._EventID;
                        dbd.SubmitChanges();
                        return("success");
                    }
                }
                catch (Exception)
                {
                    return("failed");
                }
            }
        }
        /// <summary>
        /// Gets a ticket from the DB
        /// </summary>
        ///
        /// <param name="iD">Event ID</param>
        /// <returns>Matching Event</returns>
        internal EventTicket GetActiveTicket(int iD)
        {
            EventTicket ticket = new EventTicket();
            String      sqlQ   = $"SELECT * FROM [EventTicket] WHERE [EventID] = {iD} AND Active = 1 AND [UserID] IS NULL";

            using (SqlCommand command = new SqlCommand(sqlQ, Connection))
            {
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ticket.ID      = reader.GetInt32(0);
                        ticket.EventID = reader.GetInt32(2);
                        ticket.Price   = reader.GetDouble(4);
                        ticket.Active  = reader.GetBoolean(5);
                    }
                }
            }

            return(ticket);
        }
Example #18
0
        //updateTicket
        //string UpdateTiket(EventTicket _ticket)
        public string UpdateTiket(EventTicket ticket)
        {
            try
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(
                    typeof(EventTicket));
                MemoryStream mem = new MemoryStream();
                ser.WriteObject(mem, ticket);
                string    data      = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
                WebClient webClient = new WebClient();
                webClient.Headers["Content-type"] = "application/json";
                webClient.Encoding = Encoding.UTF8;
                string response = webClient.UploadString(BASE_URL + "UpdateTiket", "PUT", data);

                return(response);
            }
            catch (Exception)
            {
                return("fail");
            }
        }
Example #19
0
 //Update for purchase
 public int PurchaseTicket(EventTicket ticket)
 {
     try
     {
         DataContractJsonSerializer ser = new DataContractJsonSerializer(
             typeof(EventTicket));
         MemoryStream mem = new MemoryStream();
         ser.WriteObject(mem, ticket);
         string    data      = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
         WebClient webClient = new WebClient();
         webClient.Headers["Content-type"] = "application/json";
         webClient.Encoding = Encoding.UTF8;
         string response = webClient.UploadString(BASE_URL + "purchaseTicket", "POST", data);
         int    strID    = JsonConvert.DeserializeObject <int>(response);
         int    ID       = strID;
         return(ID);
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Example #20
0
 public bool updateTicket(EventTicket _ticket)
 {
     try
     {
         using (EventrixDBDataContext dbd = new EventrixDBDataContext())
         {
             Ticket_Template toInsert = (from st in dbd.Ticket_Templates where st.eventid.Equals(_ticket._EventID) select st).First();
             toInsert.Type         = _ticket._Type;
             toInsert.Credit       = _ticket._Credit;
             toInsert.Price        = _ticket._Price;
             toInsert.RefundPolicy = _ticket._Refund;
             toInsert.StartDate    = _ticket._StartDate;
             toInsert.EndDate      = _ticket._EndDate;
             toInsert.eventid      = _ticket._EventID;
             //    toInsert.G_ID = _ticket._GuestID;
             dbd.SubmitChanges();
             return(true);
         };
     }catch (Exception)
     {
         return(false);
     }
 }
Example #21
0
        public int purchaseTicket(EventTicket _ticket)
        {
            string tracker = "";

            using (EventrixDBDataContext dbd = new EventrixDBDataContext())
            {
                try
                {
                    Guest_Ticket toInsert = new Guest_Ticket();
                    toInsert.G_ID           = _ticket._GuestID;
                    toInsert.ticket_temp_id = _ticket._TicketID;
                    //  toInsert.numTicket = 0;
                    dbd.Guest_Tickets.InsertOnSubmit(toInsert);
                    dbd.SubmitChanges();
                    tracker = "success";
                }
                catch (Exception)
                {
                    return(0);
                }
            };
            using (EventrixDBDataContext db = new EventrixDBDataContext())
            {
                if (tracker.Equals("success"))
                {
                    var          query = (from tk in db.Guest_Tickets select tk).ToList();
                    Guest_Ticket tick  = query.Last();
                    int          ID    = tick.ticket_Id;
                    return(ID);
                }
                else
                {
                    return(0);
                }
            };
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string eventID = Request.QueryString["ev"];
            int    G_ID    = Convert.ToInt32(Session["ID"]);

            EventModel           em           = new EventModel();
            ImageFile            img          = new ImageFile();
            List <ImageFile>     listimages   = new List <ImageFile>();
            List <EventProduct>  products     = new List <EventProduct>();
            EventTicket          EB_tickets   = new EventTicket();
            EventTicket          REG_tickets  = new EventTicket();
            EventTicket          VIP_tickets  = new EventTicket();
            EventTicket          VVIP_tickets = new EventTicket();
            EventServiceClient   eventClient  = new EventServiceClient();
            FileUploadClient     fuc          = new FileUploadClient();
            TicketServiceClient  tsc          = new TicketServiceClient();
            ProductServiceClient psc          = new ProductServiceClient();

            em         = eventClient.findByEventID(eventID);
            img        = fuc.getImageById(eventID);
            listimages = fuc.getMultipleImagesById(eventID);
            string    output      = "";
            string    imgLocation = "";
            ImageFile mainPic     = new ImageFile();

            if (listimages.Count == 0)
            {
                output = "/Events/eventrix-icon.png";
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml     = strIhtml;
                secondaryImageSlider.Visible = false;
            }
            else
            if (listimages.Count == 1)  //one pic uploaded
            {
                imgLocation = img.Location;
                output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                                                                               //image slider
                string strIhtml = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml     = strIhtml;
                secondaryImageSlider.Visible = false;
            }
            else //more than one pic uploaded
            {
                mainPic     = null;
                mainPic     = listimages.First();
                imgLocation = mainPic.Location;
                output      = imgLocation.Substring(imgLocation.IndexOf('E')); //trim string path from Event
                                                                               //image slider
                string secImageLocation = listimages[1].Location;
                string strIhtml         = "<img src='" + output + "' class='img-responsive' alt=''/>";
                divImageSlider.InnerHtml = strIhtml;
                output = secImageLocation.Substring(imgLocation.IndexOf('E'));
                string secImageSlider = "<div class='item'><img src='" + output + "' class='img-responsive' alt=''/></div>";
                secondaryImageSlider.InnerHtml = secImageSlider;
            }

            string htmltag = "";

            htmltag         = "Event Name: " + em.Name;
            EName.InnerHtml = htmltag;

            htmltag             = "<span class='title'>Start Date : </span>" + em.sDate;
            StartDate.InnerHtml = htmltag;

            htmltag           = "<span class='title'>End Date : </span>" + em.eDate;
            EndDate.InnerHtml = htmltag;

            htmltag = em.Desc;
            Description.InnerHtml = htmltag;
        }
        protected void btnComing_Click(object sender, EventArgs e)
        {
            string eventID = Request.QueryString["ev"];
            int    G_ID    = Convert.ToInt32(Session["ID"]);

            EventServiceClient event_client = new EventServiceClient();

            //Update event RSVP table
            bool isRecorded = event_client.RecordRSVP(eventID, Convert.ToString(G_ID), "Confirmed");

            //Retreive event info
            EventModel newEvent     = new EventModel();
            EventModel updatedEvent = new EventModel();

            newEvent = event_client.findByEventID(eventID);

            string ticket_Type = Convert.ToString(Session["TYPE"]);
            //Create BarCode
            TicketServiceClient tsc    = new TicketServiceClient();
            EventTicket         ticket = new EventTicket();

            if (ticket_Type.ToLower().Contains("early bird") && newEvent.EB_Quantity > 0)
            {
                ticket = tsc.getEBTicket(Convert.ToString(eventID));
                newEvent.EB_Quantity = newEvent.EB_Quantity - 1;
                updatedEvent         = event_client.updateEvent(newEvent, eventID);
            }
            else
            if (ticket_Type.ToLower().Contains("regular") && newEvent.Reg_Quantity > 0)
            {
                ticket = tsc.getRegularTicket(Convert.ToString(eventID));
                newEvent.Reg_Quantity = newEvent.Reg_Quantity - 1;
                updatedEvent          = event_client.updateEvent(newEvent, eventID);
            }
            else if (ticket_Type.ToLower().Contains("vip") && newEvent.VIP_Quantity > 0)
            {
                ticket = tsc.getVIPTicket(Convert.ToString(eventID));
                newEvent.VIP_Quantity = newEvent.VIP_Quantity - 1;
                updatedEvent          = event_client.updateEvent(newEvent, eventID);
            }
            else
            if (ticket_Type.ToLower().Contains("vvip") && newEvent.VVIP_Quantity > 0)
            {
                ticket = tsc.getVVIPTicket(Convert.ToString(eventID));
                newEvent.VVIP_Quantity = newEvent.VVIP_Quantity - 1;
                updatedEvent           = event_client.updateEvent(newEvent, eventID);
            }

            //Check if tickets sstill available
            if (ticket != null)
            {
                //Purchase ticket
                ticket._GuestID = G_ID;
                int ticketID = tsc.PurchaseTicket(ticket);
                if (ticketID != 0) //successfull transaction
                {
                    QRCodeImage img = new QRCodeImage();
                    img = GenerateCode(ticket, 1, Convert.ToString(G_ID), ticketID, eventID);
                    //Send Barcode to guest
                    EmailClient emails = new EmailClient();
                    //Find guest details
                    string Name    = Convert.ToString(Session["Name"]);
                    string Surname = Convert.ToString(Session["Surname"]);
                    string Email   = Convert.ToString(Session["Email"]);
                    emails.sendMsg_TicketPurchased(Name, Email, newEvent, img, ticket);
                    Response.Redirect("EventDetails.aspx?ev=" + eventID);
                }
            }
        }
Example #24
0
        private List <IOffer> ParseOffers(
            IElement parent,
            List <Category> categories,
            List <Currency> currencies,
            int localDeliveryCost)
        {
            List <IOffer> offers = new List <IOffer>();
            IOffer        offer;

            foreach (var off in parent.QuerySelectorAll("offer"))
            {
                switch (off.GetAttribute("type"))
                {
                case "vendor.model":
                    offer = new VendorModel();
                    (offer as VendorModel).TypePrefix           = off.QuerySelector("typePrefix").TextContent;
                    (offer as VendorModel).Vendor               = off.QuerySelector("vendor").TextContent;
                    (offer as VendorModel).VendorCode           = off.QuerySelector("vendorCode").TextContent;
                    (offer as VendorModel).Model                = off.QuerySelector("model").TextContent;
                    (offer as VendorModel).ManufacturerWarranty = bool.Parse(off.QuerySelector("manufacturer_warranty").TextContent);
                    (offer as VendorModel).CountryOfOrigin      = off.QuerySelector("country_of_origin").TextContent;
                    break;

                case "book":
                    offer = new Book();
                    (offer as Book).Author            = off.QuerySelector("author").TextContent;
                    (offer as Book).Name              = off.QuerySelector("name").TextContent;
                    (offer as Book).Publisher         = off.QuerySelector("publisher").TextContent;
                    (offer as Book).Series            = off.QuerySelector("series").TextContent;
                    (offer as Book).Year              = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as Book).ISBN              = off.QuerySelector("ISBN").TextContent;
                    (offer as Book).Volume            = Int32.Parse(off.QuerySelector("volume").TextContent);
                    (offer as Book).Part              = Int32.Parse(off.QuerySelector("part").TextContent);
                    (offer as Book).Language          = off.QuerySelector("language").TextContent;
                    (offer as Book).Binding           = off.QuerySelector("binding").TextContent;
                    (offer as Book).PageExtent        = Int32.Parse(off.QuerySelector("page_extent").TextContent);
                    (offer as Book).Delivery          = bool.Parse(off.QuerySelector("delivery").TextContent);
                    (offer as Book).LocalDeliveryCost = Int32.Parse(off.QuerySelector("local_delivery_cost")?.TextContent);
                    break;

                case "audiobook":
                    offer = new Audiobook();
                    (offer as Audiobook).Author          = off.QuerySelector("author").TextContent;
                    (offer as Audiobook).Name            = off.QuerySelector("name").TextContent;
                    (offer as Audiobook).Publisher       = off.QuerySelector("publisher").TextContent;
                    (offer as Audiobook).Year            = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as Audiobook).ISBN            = off.QuerySelector("ISBN").TextContent;
                    (offer as Audiobook).Language        = off.QuerySelector("language").TextContent;
                    (offer as Audiobook).PerformedBy     = off.QuerySelector("performed_by").TextContent;
                    (offer as Audiobook).PerformanceType = off.QuerySelector("performance_type").TextContent;
                    (offer as Audiobook).Storage         = off.QuerySelector("storage").TextContent;
                    (offer as Audiobook).Format          = off.QuerySelector("format").TextContent;
                    //  Formats for parse
                    string[] formats = new string[] { "h'h'm'm's's'", "m'm's's'" };
                    (offer as Audiobook).RecordingLength = TimeSpan.ParseExact(off.QuerySelector("recording_length").TextContent, formats, CultureInfo.InvariantCulture);
                    break;

                case "artist.title":
                    offer = new ArtistTitle();
                    (offer as ArtistTitle).Title        = off.QuerySelector("title").TextContent;
                    (offer as ArtistTitle).Year         = Int32.Parse(off.QuerySelector("year").TextContent);
                    (offer as ArtistTitle).Media        = off.QuerySelector("media").TextContent;
                    (offer as ArtistTitle).Artist       = off.QuerySelector("artist")?.TextContent;
                    (offer as ArtistTitle).Starring     = off.QuerySelector("starring")?.TextContent?.Split(',');
                    (offer as ArtistTitle).Director     = off.QuerySelector("director")?.TextContent;
                    (offer as ArtistTitle).OriginalName = off.QuerySelector("originalName")?.TextContent;
                    (offer as ArtistTitle).Country      = off.QuerySelector("country")?.TextContent;
                    break;

                case "tour":
                    offer = new Tour();
                    (offer as Tour).WorldRegion   = off.QuerySelector("worldRegion").TextContent;
                    (offer as Tour).Country       = off.QuerySelector("country").TextContent;
                    (offer as Tour).Region        = off.QuerySelector("region").TextContent;
                    (offer as Tour).Days          = Int32.Parse(off.QuerySelector("days").TextContent);
                    (offer as Tour).DataTourStart = DateTime.Parse(off.QuerySelectorAll("dataTour")[0].TextContent, CultureInfo.InvariantCulture);
                    (offer as Tour).DataTourEnd   = DateTime.Parse(off.QuerySelectorAll("dataTour")[1].TextContent, CultureInfo.InvariantCulture);
                    (offer as Tour).Name          = off.QuerySelector("name").TextContent;
                    (offer as Tour).HotelStars    = Int32.Parse(off.QuerySelector("hotel_stars").TextContent.Replace("*", string.Empty));
                    (offer as Tour).Room          = off.QuerySelector("room").TextContent;
                    (offer as Tour).Meal          = off.QuerySelector("meal").TextContent;
                    (offer as Tour).Included      = off.QuerySelector("included").TextContent.Split(',');
                    (offer as Tour).Transport     = off.QuerySelector("transport").TextContent;
                    break;

                case "event-ticket":
                    offer = new EventTicket();
                    (offer as EventTicket).Name       = off.QuerySelector("name").TextContent;
                    (offer as EventTicket).Place      = off.QuerySelector("place").TextContent;
                    (offer as EventTicket).Hall       = off.QuerySelector("hall").TextContent;
                    (offer as EventTicket).HallPart   = off.QuerySelector("hall_part").TextContent;
                    (offer as EventTicket).Date       = DateTime.Parse(off.QuerySelector("date").TextContent, CultureInfo.InvariantCulture);
                    (offer as EventTicket).IsPremiere = Convert.ToBoolean(Int32.Parse(off.QuerySelector("is_premiere").TextContent));
                    (offer as EventTicket).IsPremiere = Convert.ToBoolean(Int32.Parse(off.QuerySelector("is_kids").TextContent));
                    break;

                default:
                    offer = new BaseOffer();
                    break;
                }
                ParseBaseOffer(off, offer, categories, currencies, localDeliveryCost);
                offers.Add(offer);
            }
            return(offers);
        }
        //====================Editing ticket=====================================
        //=======================================================================
        public bool isLoadedTicket(EventModel _event, int ID)
        {
            if (!txtE_Quantity.Text.Equals(""))
            {
                _event.EB_Quantity = Convert.ToInt32(txtE_Quantity.Text);
            }
            else
            {
                _event.EB_Quantity = 0;
            }

            if (!txtR_Quantity.Text.Equals(""))
            {
                _event.Reg_Quantity = Convert.ToInt32(txtR_Quantity.Text);
            }
            else
            {
                _event.Reg_Quantity = 0;
            }

            if (!txtV_Quantity.Text.Equals(""))
            {
                _event.VIP_Quantity = Convert.ToInt32(txtV_Quantity.Text);
            }
            else
            {
                _event.VIP_Quantity = 0;
            }
            if (!txtVV_Quantity.Text.Equals(""))
            {
                _event.VVIP_Quantity = Convert.ToInt32(txtVV_Quantity.Text);
            }
            else
            {
                _event.VVIP_Quantity = 0;
            }


            string   EB_Startdate = txtE_OpenDate.Text;
            string   EB_Enddate   = txtE_ClosingDate.Text;
            DateTime EB_SDate     = new DateTime();
            DateTime EB_EDate     = new DateTime();

            string   Reg_Startdate = txtR_OpenDate.Text;
            string   Reg_Enddate   = txtR_ClosingDate.Text;
            DateTime R_SDate       = new DateTime();
            DateTime R_EDate       = new DateTime();


            string   V_Startdate = txtV_OpenDate.Text;
            string   V_Enddate   = txtV_ClosingDate.Text;
            DateTime VIP_SDate   = new DateTime();
            DateTime VIP_EDate   = new DateTime();

            string   VV_Startdate = txtVV_OpenDate.Text;
            string   VV_Enddate   = txtVV_ClosingDate.Text;
            DateTime VVIP_SDate   = new DateTime();
            DateTime VVIP_EDate   = new DateTime();


            if (!txtE_OpenDate.Text.Equals(""))
            {
                EB_SDate = DateTime.Parse(EB_Startdate, new CultureInfo("en-US", true));
            }

            if (!txtE_ClosingDate.Text.Equals(""))
            {
                EB_EDate = DateTime.Parse(EB_Enddate, new CultureInfo("en-US", true));
            }

            if (!txtR_OpenDate.Text.Equals(""))
            {
                R_SDate = DateTime.Parse(Reg_Startdate, new CultureInfo("en-US", true));
            }

            if (!txtR_ClosingDate.Text.Equals(""))
            {
                R_EDate = DateTime.Parse(Reg_Enddate, new CultureInfo("en-US", true));
            }

            if (!txtV_OpenDate.Text.Equals(""))
            {
                VIP_SDate = DateTime.Parse(V_Startdate, new CultureInfo("en-US", true));
            }

            if (!txtV_ClosingDate.Text.Equals(""))
            {
                VIP_EDate = DateTime.Parse(V_Enddate, new CultureInfo("en-US", true));
            }

            if (!txtVV_OpenDate.Text.Equals(""))
            {
                VVIP_SDate = DateTime.Parse(VV_Startdate, new CultureInfo("en-US", true));
            }

            if (!txtVV_ClosingDate.Text.Equals(""))
            {
                VVIP_EDate = DateTime.Parse(VV_Enddate, new CultureInfo("en-US", true));
            }

            //Check price
            decimal EB_Price;

            if (!txtE_Price.Text.Equals(""))
            {
                EB_Price = Convert.ToDecimal(txtE_Price.Text);
            }
            else
            {
                EB_Price = 0;
            }

            decimal R_Price;

            if (!txtR_Price.Text.Equals(""))
            {
                R_Price = Convert.ToDecimal(txtR_Price.Text);
            }
            else
            {
                R_Price = 0;
            }

            decimal V_Price;

            if (!txtV_Price.Text.Equals(""))
            {
                V_Price = Convert.ToDecimal(txtV_Price.Text);
            }
            else
            {
                V_Price = 0;
            }

            decimal VV_Price;

            if (!txtVV_Price.Text.Equals(""))
            {
                VV_Price = Convert.ToDecimal(txtVV_Price.Text);
            }
            else
            {
                VV_Price = 0;
            }


            //Check tokens
            int EB_Token;

            if (!txtE_Token.Text.Equals(""))
            {
                EB_Token = Convert.ToInt32(txtE_Token.Text);
            }
            else
            {
                EB_Token = 0;
            }

            int R_Token;

            if (!txtR_Token.Text.Equals(""))
            {
                R_Token = Convert.ToInt32(txtR_Token.Text);
            }
            else
            {
                R_Token = 0;
            }

            int V_Token;

            if (!txtV_Token.Text.Equals(""))
            {
                V_Token = Convert.ToInt32(txtV_Token.Text);
            }
            else
            {
                V_Token = 0;
            }

            int VV_Token;

            if (!txtVV_Token.Text.Equals(""))
            {
                VV_Token = Convert.ToInt32(txtVV_Token.Text);
            }
            else
            {
                VV_Token = 0;
            }


            bool controller = false;

            if (_event.EB_Quantity != 0)
            {
                EventTicket         EB_Ticket = new EventTicket();
                TicketServiceClient tsc       = new TicketServiceClient();
                //  EB_Ticket._GuestID = null;
                EB_Ticket._EventID   = ID;
                EB_Ticket._Type      = "Early Bird";
                EB_Ticket._Credit    = EB_Token;
                EB_Ticket._Refund    = "No refund";
                EB_Ticket._StartDate = EB_SDate;
                EB_Ticket._EndDate   = EB_EDate;
                EB_Ticket._Price     = EB_Price;

                string ticketresponse = tsc.UpdateTiket(EB_Ticket);
                string res            = ticketresponse;
                if (ticketresponse.Contains("success"))
                {
                    controller = true;
                }
                else
                {
                    controller = false;
                }
            }

            if (_event.Reg_Quantity != 0)
            {
                EventTicket         R_Ticket = new EventTicket();
                TicketServiceClient tsc      = new TicketServiceClient();
                //  EB_Ticket._GuestID = null;
                R_Ticket._EventID   = ID;
                R_Ticket._Type      = "Regular";
                R_Ticket._Credit    = R_Token;
                R_Ticket._Refund    = "No refund";
                R_Ticket._StartDate = R_SDate;
                R_Ticket._EndDate   = R_EDate;
                R_Ticket._Price     = R_Price;

                string ticketresponse = tsc.UpdateTiket(R_Ticket);
                string res            = ticketresponse;
                if (ticketresponse.Contains("success"))
                {
                    controller = true;
                }
                else
                {
                    controller = false;
                }
            }

            if (_event.VIP_Quantity != 0)
            {
                EventTicket         VIP_Ticket = new EventTicket();
                TicketServiceClient tsc        = new TicketServiceClient();
                //  EB_Ticket._GuestID = null;
                VIP_Ticket._EventID   = ID;
                VIP_Ticket._Type      = "VIP";
                VIP_Ticket._Credit    = V_Token;
                VIP_Ticket._Refund    = "No refund";
                VIP_Ticket._StartDate = VIP_SDate;
                VIP_Ticket._EndDate   = VIP_EDate;
                VIP_Ticket._Price     = V_Price;

                string ticketresponse = tsc.UpdateTiket(VIP_Ticket);
                string res            = ticketresponse;
                if (ticketresponse.Contains("success"))
                {
                    controller = true;
                }
                else
                {
                    controller = false;
                }
            }
            if (_event.VVIP_Quantity != 0)
            {
                EventTicket         VVIP_Ticket = new EventTicket();
                TicketServiceClient tsc         = new TicketServiceClient();
                //  EB_Ticket._GuestID = null;
                VVIP_Ticket._EventID   = ID;
                VVIP_Ticket._Type      = "VVIP";
                VVIP_Ticket._Credit    = VV_Token;
                VVIP_Ticket._Refund    = "No refund";
                VVIP_Ticket._StartDate = VVIP_SDate;
                VVIP_Ticket._EndDate   = VVIP_EDate;
                VVIP_Ticket._Price     = VV_Price;

                string ticketresponse = tsc.UpdateTiket(VVIP_Ticket);
                string res            = ticketresponse;
                if (ticketresponse.Contains("success"))
                {
                    controller = true;
                }
                else
                {
                    controller = false;
                }
            }
            return(controller);
        }
        public static async Task SeedData(IServiceProvider serviceProvider)
        {
            using (var context = new ApplicationDbContext(serviceProvider.GetRequiredService <DbContextOptions <ApplicationDbContext> >()))
            {
                if (context.DeviceScales.Count() == 0)
                {
                    var ds = new DeviceScale()
                    {
                        DeviceScaleId         = Guid.NewGuid(),
                        DeviceName            = "CardinalRPI01",
                        DeviceScaleType       = DeviceScaleType.RPIwithHX711max5kg,
                        DebugMode             = true,
                        CalibrationConstant   = -389,
                        CalibrationUnits      = "g",
                        CalibrationUnitsLong  = "grams",
                        RefreshMilliseconds   = 250,
                        StableCount           = 2,
                        StableThreshold       = 2,
                        ReadCountAverage      = 5,
                        ReadCountMilliseconds = 10
                    };
                    await context.DeviceScales.AddAsync(ds);

                    await context.SaveChangesAsync();
                }

                if (context.PourSpouts.Count() == 0)
                {
                    var spillstop01 = new PourSpout()
                    {
                        PourSpoutId         = Guid.NewGuid(),
                        Description         = "Spill-Stop 285-50",
                        DurationForOneLiter = 51.14,
                        ImagePath           = "spill-stop-285-50.jpg"
                    };
                    await context.PourSpouts.AddAsync(spillstop01);

                    await context.SaveChangesAsync();

                    var spillstop02 = new PourSpout()
                    {
                        PourSpoutId         = Guid.NewGuid(),
                        Description         = "Spill-Stop 285-60",
                        DurationForOneLiter = 51.14,
                        ImagePath           = "spill-stop-285-60.jpg"
                    };
                    await context.PourSpouts.AddAsync(spillstop02);

                    await context.SaveChangesAsync();
                }

                if (context.Events.Count() == 0)
                {
                    var station = new EventStation()
                    {
                        EventStationId = Guid.NewGuid(),
                        Description    = "TestStation01",
                        Hardware       = EventStationHardware.RPIwithPN532
                    };
                    await context.EventStations.AddAsync(station);

                    await context.SaveChangesAsync();

                    var evt = new Event()
                    {
                        EventId     = Guid.NewGuid(),
                        Description = "TestEvent",
                        Completed   = false
                    };
                    await context.Events.AddAsync(evt);

                    await context.SaveChangesAsync();

                    var admissionType = new EventTicketAdmissionType()
                    {
                        EventTicketAdmissionTypeId = Guid.NewGuid(),
                        Description = "General Admission",
                        EventId     = evt.EventId,
                        Level       = 1
                    };
                    await context.EventTicketAdmissionTypes.AddAsync(admissionType);

                    await context.SaveChangesAsync();

                    var admissionTypeVIP = new EventTicketAdmissionType()
                    {
                        EventTicketAdmissionTypeId = Guid.NewGuid(),
                        Description = "VIP",
                        EventId     = evt.EventId,
                        Level       = 10
                    };
                    await context.EventTicketAdmissionTypes.AddAsync(admissionTypeVIP);

                    await context.SaveChangesAsync();

                    var stationAssignment = new EventStationAssignment()
                    {
                        EventId                        = evt.EventId,
                        EventStationId                 = station.EventStationId,
                        ControlType                    = EventStationControlType.EntryGate,
                        EventTicketAdmissionTypeId     = admissionType.EventTicketAdmissionTypeId,
                        GateEventTicketAdmissionTypeId = admissionType.EventTicketAdmissionTypeId
                    };
                    await context.EventStationAssignments.AddAsync(stationAssignment);

                    await context.SaveChangesAsync();

                    var cust = new EventCustomer()
                    {
                        EventCustomerId = Guid.NewGuid(),
                        Email           = "*****@*****.**",
                        FirstName       = "Ryan",
                        LastName        = "Rauch",
                        TimeStamp       = DateTime.Now
                    };
                    await context.EventCustomers.AddAsync(cust);

                    await context.SaveChangesAsync();

                    var ticket = new EventTicket()
                    {
                        EventTicketId = Guid.NewGuid(),
                        EventId       = evt.EventId,
                        EventTicketAdmissionTypeId = admissionType.EventTicketAdmissionTypeId,
                        UniqueIdentifier           = "TESTTICKET01",
                        TicketPhysicalType         = TicketPhysicalType.PaperQRcode,
                        EventCustomerId            = cust.EventCustomerId,
                        Enabled = true
                    };
                    await context.EventTickets.AddAsync(ticket);

                    await context.SaveChangesAsync();
                }

                if (context.Bars.Count() == 0)
                {
                    var company = new Company()
                    {
                        CompanyId   = Guid.NewGuid(),
                        Description = "Union Venture Group",
                        Active      = true
                    };
                    await context.Companies.AddAsync(company);

                    await context.SaveChangesAsync();

                    var b = new Bar()
                    {
                        BarId       = Guid.NewGuid(),
                        CompanyId   = company.CompanyId,
                        Description = "Jack & Ginger's Irish Pub",
                        Active      = true
                    };
                    await context.Bars.AddAsync(b);

                    await context.SaveChangesAsync();

                    var building = new Building()
                    {
                        BuildingId  = Guid.NewGuid(),
                        BarId       = b.BarId,
                        Description = "11500B Rock Rose",
                        Active      = true
                    };
                    await context.Buildings.AddAsync(building);

                    await context.SaveChangesAsync();

                    var floor = new Floor()
                    {
                        FloorId     = Guid.NewGuid(),
                        Description = "Ground-Level",
                        BuildingId  = building.BuildingId,
                        Active      = true
                    };
                    await context.Floors.AddAsync(floor);

                    await context.SaveChangesAsync();

                    var outside = new Area()
                    {
                        AreaId      = Guid.NewGuid(),
                        FloorId     = floor.FloorId,
                        Description = "Outside Bar",
                        Active      = true
                    };
                    await context.Areas.AddAsync(outside);

                    await context.SaveChangesAsync();
                }
                if (context.StockItems.Count() == 0)
                {
                    var titos = new StockItem()
                    {
                        StockItemId         = Guid.NewGuid(),
                        Description         = "Tito's Handmade Vodka 1L",
                        SKU                 = "1994700001",
                        ImagePath           = "titos-handmade-vodka-1L.png",
                        UnitSizeMilliliters = 1000
                    };
                    await context.StockItems.AddAsync(titos);

                    await context.SaveChangesAsync();

                    var stitos = new SerializedStockItem()
                    {
                        SerializedStockItemId = Guid.NewGuid(),
                        StockItemId           = titos.StockItemId,
                        Barcode          = "01209920",
                        CurrentItemLevel = 1.0M,
                        ReceivedDate     = DateTime.Now,
                        LastModifiedDate = DateTime.Now
                    };
                    await context.SerializedStockItems.AddAsync(stitos);

                    await context.SaveChangesAsync();

                    var jameson = new StockItem()
                    {
                        StockItemId         = Guid.NewGuid(),
                        Description         = "Jameson Irish Whiskey 1L",
                        SKU                 = "8043250011",
                        ImagePath           = "jameson-irish-whiskey-1L.png",
                        UnitSizeMilliliters = 1000
                    };
                    await context.StockItems.AddAsync(jameson);

                    await context.SaveChangesAsync();

                    var sjameson = new SerializedStockItem()
                    {
                        SerializedStockItemId = Guid.NewGuid(),
                        StockItemId           = jameson.StockItemId,
                        Barcode          = "01209914",
                        CurrentItemLevel = 1.0M,
                        ReceivedDate     = DateTime.Now,
                        LastModifiedDate = DateTime.Now
                    };
                    await context.SerializedStockItems.AddAsync(sjameson);

                    await context.SaveChangesAsync();
                }

                /*if (context.StockItems.Count() == 0)
                 * {
                 *  //var sic = new StockItemCategory()
                 *  //{
                 *  //    StockItemCategoryId = Guid.NewGuid(),
                 *  //    Description = "Whiskey"
                 *  //};
                 *  //await context.StockItemCategories.AddAsync(sic);
                 *
                 *  var whiskey01 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Bulleit Bourbon",
                 *      ImagePath = "bulleit-bourbon-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 19.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey01);
                 *
                 *  var whiskey02 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Fireball Cinnamon Whisky",
                 *      ImagePath = "fireball-cinnamon-whisky-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 11.49M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey02);
                 *
                 *  var whiskey03 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Jameson Irish Whiskey",
                 *      ImagePath = "jameson-irish-whiskey-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 16.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey03);
                 *
                 *  var whiskey04 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Maker's Mark Bourbon Whisky",
                 *      ImagePath = "makers-mark-bourbon-whisky-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 19.98M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey04);
                 *
                 *  var whiskey05 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Jack Daniel's Old No. 7 Whiskey",
                 *      ImagePath = "jack-daniels-old-no-7-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 12.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey05);
                 *
                 *  var whiskey06 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Jim Beam Bourbon Whiskey",
                 *      ImagePath = "jim-beam-bourbon-whiskey-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 9.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey06);
                 *
                 *  var whiskey07 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Johnnie Walker Black Label",
                 *      ImagePath = "johnnie-walker-black-label-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 24.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey07);
                 *
                 *  var whiskey08 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Evan Williams Bourbon Whiskey Black Label",
                 *      ImagePath = "evan-williams-black-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 8.79M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey08);
                 *
                 *  var whiskey09 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Bulleit Rye",
                 *      ImagePath = "bulleit-rye-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 19.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey09);
                 *
                 *  var whiskey10 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Crown Royal Deluxe",
                 *      ImagePath = "crown-royal-deluxe-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 9.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey10);
                 *
                 *  var whiskey11 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Buffalo Trace Bourbon",
                 *      ImagePath = "buffalo-trace-bourbon-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 9.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey11);
                 *
                 *  var whiskey12 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Knob Creek Kentucky Straight Bourbon Whiskey",
                 *      ImagePath = "knob-creek-kentucky-straight-bourbon-whiskey-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 22.80M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey12);
                 *
                 *  var whiskey13 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Woodford Reserve Bourbon",
                 *      ImagePath = "woodford-reserve-bourbon-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 22.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey13);
                 *
                 *  var whiskey14 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Basil Hayden's Kentucky Straight Bourbon Whiskey",
                 *      ImagePath = "basil-haydens-kentucky-straight-bourbon-whiskey-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 22.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey14);
                 *
                 *  var whiskey15 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "The Macallan 12 Year Sherry Oak",
                 *      ImagePath = "the-macallan-sherry-oak-12-year-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 47.25M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey15);
                 *
                 *  var whiskey16 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Seagram's 7 Crown Blended Whiskey",
                 *      ImagePath = "seagrams-7-crown-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 8.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey16);
                 *
                 *  var whiskey17 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Four Roses Bourbon",
                 *      ImagePath = "four-roses-bourbon-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 13.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey17);
                 *
                 *  var whiskey18 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Jack Daniel's Tennessee Honey",
                 *      ImagePath = "jack-daniels-tennessee-honey-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 16.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey18);
                 *
                 *  var whiskey19 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Dewar's White Label",
                 *      ImagePath = "dewars-white-label-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 17.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey19);
                 *
                 *  var whiskey20 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Hibiki Japanese Harmony Whisky",
                 *      ImagePath = "hibiki-japanese-harmony-whisky-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 57.10M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey20);
                 *
                 *  var whiskey21 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Old Overholt Rye Whiskey",
                 *      ImagePath = "old-overholt-original-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 12.49M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey21);
                 *
                 *  var whiskey22 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Johnnie Walker Red Label",
                 *      ImagePath = "johnnie-walker-red-label-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 14.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey22);
                 *
                 *  var whiskey23 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Lagavulin 16 Year",
                 *      ImagePath = "lagavulin-16-year-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 61.52M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey23);
                 *
                 *  var whiskey24 = new StockItem()
                 *  {
                 *      //StockItemCategoryId = sic.StockItemCategoryId,
                 *      StockItemId = Guid.NewGuid(),
                 *      Description = "Crown Royal Apple",
                 *      ImagePath = "crown-royal-regal-apple-1L.png",
                 *      UnitSizeMilliliters = 1000,
                 *      UnitCost = 18.99M
                 *  };
                 *  await context.StockItems.AddAsync(whiskey24);
                 * }
                 */
                await context.SaveChangesAsync();
            }
        }
Example #27
0
 public bool deleteTicket(EventTicket _ticket)
 {
     throw new NotImplementedException();
 }
Example #28
0
        public async Task BankRunAppSelector(string selectedProcess, Guid?bankRunGUID, Guid?entityId, string entityName)
        {
            logger.LogInformation("----------Entering BankRunAppSelector()----------");


            try
            {
                #region Bank Run Generate List
                // ----------Bank Run Generate List----------
                if (selectedProcess.Equals("List"))
                {
                    BankRun bankRunEntity = BankRunFileReport.GetBankRunEntityFromId(bankRunGUID, this.context);

                    if (bankRunEntity == null)
                    {
                        logger.LogInformation("Exiting web job.");
                        return;
                    }

                    // Assign the payment schedules to the bank run:
                    BankRunGenerateList.GetPaymentSchedulesForBankRun(bankRunEntity, context, this.logger);
                    // Now do the same for one off transactions (TODO in future sprint).

                    try
                    {
                        // Update the Bankrun Status to "Report Available" (844060004):
                        BankRun bankRunToUpdate = new BankRun();
                        bankRunToUpdate.BankRunId     = bankRunEntity.BankRunId;
                        bankRunToUpdate.BankRunStatus = 844060004;
                        logger.LogInformation("Updating BankRun Status.");
                        await this.xrmService.UpdateAsync(bankRunToUpdate);

                        logger.LogInformation("Updated BankRun Status to \"Report Available\" successfully.");
                    }
                    catch (Exception ex)
                    {
                        logger.LogError("Could not Update Bank Run Status. Exception:" + ex.Message);
                    }
                }
                #endregion
                #region Bank Run Generate File
                // ----------Bank Run Generate File----------
                else if (selectedProcess.Equals("File"))
                {
                    BankRun bankRunEntity = BankRunFileReport.GetBankRunEntityFromId(bankRunGUID, this.context);
                    //Configuration configEntity = Common.GetConfigurationEntityFromId(configGuid, this.DataContext);
                    PaymentProcessor paymentProcessorEntity = BankRunFileReport.GetPaymentProcessorEntityFromBankRun(bankRunEntity, this.context, this.logger);
                    PaymentMethod    paymentMethodEntity    = BankRunFileReport.GetPaymentMethodEntityFromBankRun(bankRunEntity, this.context, this.logger);

                    int?bankRunFileFormat = paymentProcessorEntity.BankRunFileFormat;
                    logger.LogInformation("Requested Bank Run File Format:" + bankRunFileFormat);

                    BankRunFileReport bankRunFileReport;
                    switch (bankRunFileFormat)
                    {
                    case (int)BankRunFileFormat.ABA:
                        bankRunFileReport = new AbaFileReport(bankRunEntity, paymentProcessorEntity, paymentMethodEntity, this.context, this.logger);
                        break;

                    case (int)BankRunFileFormat.BMO:
                        bankRunFileReport = new BMOFileReport(bankRunEntity, paymentProcessorEntity, paymentMethodEntity, this.context, this.logger);
                        break;

                    case (int)BankRunFileFormat.ScotiaBank:
                        bankRunFileReport = new ScotiaBankFileReport(bankRunEntity, paymentProcessorEntity, paymentMethodEntity, this.context, this.logger);
                        break;

                    case null:
                        throw new Exception("No Bank Run File Format set on the Payment Processor with ID:" + paymentProcessorEntity.PaymentProcessorId);

                    default:
                        throw new Exception("Can't find Bank Run File Format for provided value:" + bankRunFileFormat);
                    }

                    await bankRunFileReport.GenerateFileReport();

                    await bankRunFileReport.SaveReport();
                }
                #endregion
                #region Bank Run Generate Recurring Donation Records
                else if (selectedProcess.Equals("GenerateTransactions"))
                {
                    BankRun bankRunEntity = BankRunFileReport.GetBankRunEntityFromId(bankRunGUID, this.context);
                    BankRunRecurringDonations.GenerateBankRunRecurringDonations(bankRunEntity, this.context, this.logger);
                }
                #endregion

                #region Event Receipting
                else if (selectedProcess.Equals("EventReceipting") && entityId.HasValue)
                {
                    List <EventPackage> eventPackages = new List <EventPackage>();
                    switch (entityName)
                    {
                    case EventReceipting.EventTicket:
                        EventTicket eventTicket = EventReceipting.GetEventTicketFromId(entityId.Value, this.context);
                        EventReceipting.UpdateTicketsFromEventTicket(eventTicket, this.context);
                        eventPackages = EventReceipting.GetEventPackagesFromEventTicket(eventTicket, this.context);
                        break;

                    case EventReceipting.EventProduct:
                        EventProduct eventProduct = EventReceipting.GetEventProductFromId(entityId.Value, this.context);
                        EventReceipting.UpdateProductsFromEventProduct(eventProduct, this.context);
                        eventPackages = EventReceipting.GetEventPackagesFromEventProduct(eventProduct, this.context);
                        break;

                    case EventReceipting.EventSponsorship:
                        EventSponsorship eventSponsorship = EventReceipting.GetEventSponsorshipFromId(entityId.Value, this.context);
                        EventReceipting.UpdateSponsorshipsFromEventSponsorship(eventSponsorship, this.context);
                        eventPackages = EventReceipting.GetEventPackagesFromEventSponsorship(eventSponsorship, this.context);
                        break;

                    default:
                        throw new Exception("Unknown Entity for Event Receipting: " + entityName + ". Exiting.");
                    }

                    EventReceipting.UpdateEventPackages(eventPackages, this.context);
                }

                #endregion
            }
            catch (Exception e)
            {
                logger.LogError("Error in BankRunAppSelector(): " + e.Message);
                if (e.InnerException != null)
                {
                    logger.LogError("Inner exception: " + e.InnerException.ToString());
                }
            }

            logger.LogInformation("----------Exiting BankRunAppSelector()----------");
            logger.LogInformation("----------Exiting Web Job----------");
        }
Example #29
0
        //Sending Email with the purchased Qr-Code
        public void sendMsg_TicketPurchased(string GuestName, string GuestEmail, EventModel _event, QRCodeImage QRCode, EventTicket ticket)
        {
            SmtpClient smtp = new SmtpClient();

            smtp.Host        = "smtp.gmail.com";
            smtp.Port        = 587;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "*****@*****.**");
            smtp.EnableSsl   = true;

            MailMessage msg = new MailMessage();

            msg.Subject = "Ticket Purchased for " + _event.Name;
            msg.Body    = "Hi " + GuestName + ",";
            msg.Body   += "<tr><td>Herewith purchased Ticket for :" + _event.Name + "</td></tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td><img src='" + _event.ImageLocation + "' alt=''/></td>";
            msg.Body   += "</tr>";
            msg.Body   += "<tr>";
            msg.Body   += "<td>" + _event.eDate + "</td>";
            msg.Body   += "</tr>";
            //msg.Body += "<tr>";
            //msg.Body += "<td>" + _event.Eve + "</td>";
            //msg.Body += "</tr>";
            msg.Body += "<tr>";
            msg.Body += "<td>Ticket Details: </td>";
            msg.Body += "</tr>";
            msg.Body += "<tr>";
            msg.Body += "<td>Type: " + ticket._Type + "</td>";     //Ticket Type
            msg.Body += "</tr>";
            msg.Body += "<tr>";
            msg.Body += "<td>Credit: " + ticket._Credit + "</td>"; //Credits
            msg.Body += "</tr>";
            msg.Body += "<tr>";
            msg.Body += "<td>Sincerely,</td>";
            msg.Body += "</tr>";
            msg.Body += "<tr>";
            msg.Body += "<td>Eventrix</td>";    //Event Host Name
            msg.Body += "</tr>";

            Attachment data = new Attachment(
                QRCode.Location,
                MediaTypeNames.Application.Octet);

            // your path may look like Server.MapPath("~/file.ABC")
            msg.Attachments.Add(data);
            string toAddress = GuestEmail; // Add Recepient address

            msg.To.Add(toAddress);
            msg.To.Add(new MailAddress(toAddress));

            string FromAddress = "*****@*****.**";

            msg.From       = new MailAddress(FromAddress);
            msg.IsBodyHtml = true;

            try
            {
                smtp.Send(msg);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
        // string reqEventID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            String request = (Request.QueryString["EventID"]);

            // reqEventID = request;
            if (!IsPostBack)
            {
                if (request == null)
                {
                    request = (Request.QueryString["ed"]);
                }
                int EventID = Convert.ToInt32(request);
                strEventID = EventID;
                EventModel          em           = new EventModel();
                ImageFile           img          = new ImageFile();
                List <EventProduct> products     = new List <EventProduct>();
                EventTicket         EB_tickets   = new EventTicket();
                EventTicket         REG_tickets  = new EventTicket();
                EventTicket         VIP_tickets  = new EventTicket();
                EventTicket         VVIP_tickets = new EventTicket();
                EventAddress        _address     = new EventAddress();
                //Service Clients
                EventServiceClient   eventClient = new EventServiceClient();
                FileUploadClient     fuc         = new FileUploadClient();
                TicketServiceClient  tsc         = new TicketServiceClient();
                ProductServiceClient psc         = new ProductServiceClient();
                MappingClient        mc          = new MappingClient();

                //Gett Functions
                em = eventClient.findByEventID(request);
                string addID = Convert.ToString(em.EventAddress);
                AddressID    = Convert.ToInt32(addID);
                img          = fuc.getImageById(request);
                EB_tickets   = tsc.getEBTicket(request);
                REG_tickets  = tsc.getRegularTicket(request);
                VIP_tickets  = tsc.getVIPTicket(request);
                VVIP_tickets = tsc.getVVIPTicket(request);
                products     = psc.getProductByEventID(request);
                _address     = mc.getAddressById(addID);
                //First Tab
                divHearderName.InnerHtml = "Edit " + em.Name;
                txtEventName.Text        = em.Name;
                txtDesc.Text             = em.Desc;
                txtStart.Text            = Convert.ToString(em.sDate);
                txtEnd.Text = Convert.ToString(em.eDate);

                //Ticket Section
                if (EB_tickets == null)
                {
                    txtE_Price.Text       = "";
                    txtE_Quantity.Text    = "";
                    txtE_Token.Text       = "";
                    txtE_OpenDate.Text    = "";
                    txtE_ClosingDate.Text = "";
                }
                else
                {
                    txtE_Price.Text       = Convert.ToString(EB_tickets._Price);
                    txtE_Quantity.Text    = Convert.ToString(em.EB_Quantity);
                    txtE_Token.Text       = Convert.ToString(EB_tickets._Credit);
                    txtE_OpenDate.Text    = Convert.ToString(EB_tickets._StartDate);
                    txtE_ClosingDate.Text = Convert.ToString(EB_tickets._EndDate);
                }

                if (REG_tickets == null)
                {
                    txtR_Price.Text       = "";
                    txtR_Quantity.Text    = "";
                    txtR_Token.Text       = "";
                    txtR_OpenDate.Text    = "";
                    txtR_ClosingDate.Text = "";
                }
                else
                {
                    txtR_Price.Text       = Convert.ToString(REG_tickets._Price);
                    txtR_Quantity.Text    = Convert.ToString(em.Reg_Quantity);
                    txtR_Token.Text       = Convert.ToString(REG_tickets._Credit);
                    txtR_OpenDate.Text    = Convert.ToString(REG_tickets._StartDate);
                    txtR_ClosingDate.Text = Convert.ToString(REG_tickets._EndDate);
                }
                if (VIP_tickets == null)
                {
                    txtV_Price.Text       = "";
                    txtV_Quantity.Text    = "";
                    txtV_Token.Text       = "";
                    txtV_OpenDate.Text    = "";
                    txtV_ClosingDate.Text = "";
                }
                else
                {
                    txtV_Price.Text       = Convert.ToString(VIP_tickets._Price);
                    txtV_Quantity.Text    = Convert.ToString(em.VIP_Quantity);
                    txtV_Token.Text       = Convert.ToString(VIP_tickets._Credit);
                    txtV_OpenDate.Text    = Convert.ToString(VIP_tickets._StartDate);
                    txtV_ClosingDate.Text = Convert.ToString(VIP_tickets._EndDate);
                }

                if (VVIP_tickets == null)
                {
                    txtVV_Price.Text       = "";
                    txtVV_Quantity.Text    = "";
                    txtVV_Token.Text       = "";
                    txtVV_OpenDate.Text    = "";
                    txtVV_ClosingDate.Text = "";
                }
                else
                {
                    txtVV_Price.Text       = Convert.ToString(VVIP_tickets._Price);
                    txtVV_Quantity.Text    = Convert.ToString(em.VVIP_Quantity);
                    txtVV_Token.Text       = Convert.ToString(VVIP_tickets._Credit);
                    txtVV_OpenDate.Text    = Convert.ToString(VVIP_tickets._StartDate);
                    txtVV_ClosingDate.Text = Convert.ToString(VVIP_tickets._EndDate);
                }

                //Address
                txtStreet.Text   = _address.STREET;
                txtCity.Text     = _address.CITY;
                txtProvince.Text = _address.PROVINCE;
                txtCountry.Text  = _address.COUNTRY;
            }
        }