public ActionResult Create(Tour tour) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write)) return RedirectToAction("Index", "Home"); if (ModelState.IsValid) { UploadController uc = new UploadController(); tour.ID = Guid.NewGuid(); tour.CreatedBy = Guid.Parse(Session["userid"].ToString()); tour.CreatedOn = DateTime.Now; if (tour.AudioFile != null) { tour.AudioBlobUrl = uc.UploadFileToBlob(tour.AudioFile, tour.ID, "AudioContainerName", string.Format("{0}.{1}", tour.ID, "mp3")); } if (tour.OggAudioFile != null) { uc.UploadFileToBlob(tour.OggAudioFile, tour.ID, "AudioContainerName", string.Format("{0}.{1}", tour.ID, "wav")); } db.Tours.AddObject(tour); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", tour.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", tour.ModifiedBy); return View(tour); }
/// <summary> /// Deprecated Method for adding a new object to the Tours EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTours(Tour tour) { base.AddObject("Tours", tour); }
/// <summary> /// Create a new Tour object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="uniqueID">Initial value of the UniqueID property.</param> public static Tour CreateTour(global::System.Guid id, global::System.String name, global::System.Int32 uniqueID) { Tour tour = new Tour(); tour.ID = id; tour.Name = name; tour.UniqueID = uniqueID; return tour; }