Ejemplo n.º 1
0
        public IHttpActionResult Putuser(int id, user user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != user.userID)
            {
                return(BadRequest());
            }

            db.Entry(user).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!userExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        public IHttpActionResult PuteventsTable(int id, eventsTable eventsTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eventsTable.eventID)
            {
                return(BadRequest());
            }

            db.Entry(eventsTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!eventsTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "eventDescription,eventCategory,eventStartDate,eventEndDate,eventStartTime,eventEndTime,registration,adultPrice,childPrice,eventID,image")] eventsTable eventsTable, HttpPostedFileBase file)
        {
            //string fileName = Path.GetFileNameWithoutExtension(eventsTable.imageFile.FileName);
            //string extension = Path.GetExtension(eventsTable.imageFile.FileName);
            //fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
            //eventsTable.image = "~/Content/Images/" + fileName;
            //fileName = Path.Combine(Server.MapPath("~/Content/Images"), fileName);
            //eventsTable.imageFile.SaveAs(fileName);
            if (ModelState.IsValid)
            {
                string ImageName    = System.IO.Path.GetFileName(file.FileName);
                string physicalPath = Server.MapPath("~/Content/Images/" + ImageName);

                // save image in folder
                file.SaveAs(physicalPath);

                //save new record in database
                eventsTable.image = ImageName;
                db.eventsTables.Add(eventsTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eventsTable));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "userID,firstName,lastName,email,password,role")] user user)
        {
            if (ModelState.IsValid)
            {
                db.users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
        public ActionResult Create([Bind(Include = "eventDescription,eventCategory,eventStartDate,eventEndDate,eventStartTime,eventEndTime,registration,adultPrice,childPrice,eventID,image")] eventsTable eventsTable)
        {
            if (ModelState.IsValid)
            {
                db.eventsTables.Add(eventsTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(eventsTable));
        }
Ejemplo n.º 6
0
        public ActionResult Create(int?id, [Bind(Include = "buyerPhone,buyerAddress,totalAdult,totalChildren,ticketID,eventID,totalPrice")] ticket ticket)
        {
            if (ModelState.IsValid)
            {
                ticket.userID = Convert.ToInt32(Session["userID"]);
                var eventTable = db.eventsTables.Find(id);
                var x          = eventTable.adultPrice;
                var y          = eventTable.childPrice;
                var x1         = ticket.totalChildren;
                var y1         = ticket.totalAdult;
                var total      = (x * x1) + (y * y1);
                ticket.totalPrice = Convert.ToInt32(total);
                db.tickets.Add(ticket);
                db.SaveChanges();
                return(RedirectToAction("Index", "Confirmation", new { ticketID = ticket.ticketID, eventID = ticket.eventID }));
            }

            ViewBag.eventID = ticket.ticketID;
            //ViewBag.eventID = new SelectList(db.eventsTables, "eventID", "eventDescription", ticket.eventID);
            //ViewBag.userID = new SelectList(db.users, "userID", "firstName", ticket.userID);
            return(View(ticket));
        }