コード例 #1
0
ファイル: TourController.cs プロジェクト: fashaikh/ChronoZoom
        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);
        }
コード例 #2
0
        public ActionResult Edit(Tour tour)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                UploadController uc = new UploadController();
                tour.ModifiedBy = Guid.Parse(Session["userid"].ToString());
                tour.ModifiedOn = 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.Attach(tour);
                db.ObjectStateManager.ChangeObjectState(tour, EntityState.Modified);
                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));
        }
コード例 #3
0
        public ActionResult Create(ContentItem contentitem)
        {
            if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write))
                return RedirectToAction("Index", "Home");
            if (ModelState.IsValid)
            {
                contentitem.ID = Guid.NewGuid();
                contentitem.CreatedBy = Guid.Parse(Session["userid"].ToString());
                contentitem.CreatedOn = DateTime.Now;

                if (contentitem.ImageFile != null)
                {
                    UploadController uc = new UploadController();
                    contentitem.MediaBlobURL = uc.UploadFileToBlob(contentitem.ImageFile, contentitem.ID, "ImageContainerName", string.Empty);
                }

                if (!string.IsNullOrEmpty(contentitem.MediaBlobURL))
                {
                    db.ContentItems.AddObject(contentitem);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }

            ViewBag.LicenseTypeID = new SelectList(db.LicenseTypes.Where(l => l.IsDeleted == null || l.IsDeleted == false), "ID", "LicenseType1", contentitem.LicenseTypeID);
            ViewBag.MediaTypeID = new SelectList(db.MediaTypes.Where(m => m.IsDeleted == null || m.IsDeleted == false), "ID", "MediaType1", contentitem.MediaTypeID);
            ViewBag.RegimeID = new SelectList(db.Regimes.Where(r => r.IsDeleted == null || r.IsDeleted == false), "ID", "Regime1", contentitem.RegimeID);
            ViewBag.ThresholdID = new SelectList(db.Thresholds.Where(t => t.IsDeleted == null || t.IsDeleted == false), "ID", "Threshold1", contentitem.ThresholdID);
            ViewBag.TimeUnitID = new SelectList(db.TimeUnits.Where(tu => tu.IsDeleted == null || tu.IsDeleted == false), "ID", "TimeUnit1", contentitem.TimeUnitID);
            ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", contentitem.CreatedBy);
            ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", contentitem.ModifiedBy);

            return View(contentitem);
        }
コード例 #4
0
 public ActionResult Edit(ContentItem contentitem)
 {
     if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, write))
     {
         return(RedirectToAction("Index", "Home"));
     }
     if (ModelState.IsValid)
     {
         contentitem.ModifiedBy  = Guid.Parse(Session["userid"].ToString());
         contentitem.ModifiedOn  = DateTime.Now;
         contentitem.MediaTypeID = Guid.Parse(Request.Form["MediaTypeIDList"]);
         if (contentitem.ImageFile != null)
         {
             UploadController uc = new UploadController();
             contentitem.MediaBlobURL = uc.UploadFileToBlob(contentitem.ImageFile, contentitem.ID, "ImageContainerName", string.Empty);
         }
         db.ContentItems.Attach(contentitem);
         db.ObjectStateManager.ChangeObjectState(contentitem, EntityState.Modified);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.LicenseTypeID = new SelectList(db.LicenseTypes.Where(l => l.IsDeleted == null || l.IsDeleted == false), "ID", "LicenseType1", contentitem.LicenseTypeID);
     ViewBag.MediaTypeID   = new SelectList(db.MediaTypes.Where(m => m.IsDeleted == null || m.IsDeleted == false), "ID", "MediaType1", contentitem.MediaTypeID);
     ViewBag.RegimeID      = new SelectList(db.Regimes.Where(r => r.IsDeleted == null || r.IsDeleted == false), "ID", "Regime1", contentitem.RegimeID);
     ViewBag.ThresholdID   = new SelectList(db.Thresholds.Where(t => t.IsDeleted == null || t.IsDeleted == false), "ID", "Threshold1", contentitem.ThresholdID);
     ViewBag.TimeUnitID    = new SelectList(db.TimeUnits.Where(tu => tu.IsDeleted == null || tu.IsDeleted == false), "ID", "TimeUnit1", contentitem.TimeUnitID);
     ViewBag.CreatedBy     = new SelectList(db.Users, "ID", "UserName", contentitem.CreatedBy);
     ViewBag.ModifiedBy    = new SelectList(db.Users, "ID", "UserName", contentitem.ModifiedBy);
     return(View(contentitem));
 }