예제 #1
0
 public ActionResult Rate([Bind(Include = "BookingId,EventId,CustomerId,EventDate,BookingDate,Status,NumberOfPeople,Remarks,Rating")] Booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(booking));
 }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,Email,Phone,Latitude,Longitude")] Location location)
        {
            if (ModelState.IsValid)
            {
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Description,Optional_Services,BasePrice")] Event @event, HttpPostedFileBase postedFile)
        {
            var myUniqueFileName = string.Format(@"{0}", Guid.NewGuid());

            @event.ImagePath = myUniqueFileName;
            if (ModelState.IsValid)
            {
                @event.Name              = Sanitizer.GetSafeHtmlFragment(@event.Name);
                @event.Description       = Sanitizer.GetSafeHtmlFragment(@event.Description);
                @event.Optional_Services = Sanitizer.GetSafeHtmlFragment(@event.Optional_Services);

                string serverPath    = System.Web.Hosting.HostingEnvironment.MapPath("~/Uploads/");
                string fileExtension = Path.GetExtension(postedFile.FileName);
                string filePath      = @event.ImagePath + fileExtension;
                @event.ImagePath = filePath;
                postedFile.SaveAs(serverPath + @event.ImagePath);

                db.Events.Add(@event);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(@event));
        }