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); }
/// <summary> /// Deprecated Method for adding a new object to the ContentItems EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToContentItems(ContentItem contentItem) { base.AddObject("ContentItems", contentItem); }
/// <summary> /// Create a new ContentItem object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="caption">Initial value of the Caption property.</param> /// <param name="topic">Initial value of the Topic property.</param> /// <param name="mediaTypeID">Initial value of the MediaTypeID property.</param> /// <param name="thresholdID">Initial value of the ThresholdID property.</param> /// <param name="regimeID">Initial value of the RegimeID property.</param> /// <param name="mediaBlobURL">Initial value of the MediaBlobURL property.</param> /// <param name="timeUnitID">Initial value of the TimeUnitID property.</param> /// <param name="licenseTypeID">Initial value of the LicenseTypeID property.</param> /// <param name="uniqueID">Initial value of the UniqueID property.</param> public static ContentItem CreateContentItem(global::System.Guid id, global::System.String title, global::System.String caption, global::System.String topic, global::System.Guid mediaTypeID, global::System.Guid thresholdID, global::System.Guid regimeID, global::System.String mediaBlobURL, global::System.Guid timeUnitID, global::System.Guid licenseTypeID, global::System.Int32 uniqueID) { ContentItem contentItem = new ContentItem(); contentItem.ID = id; contentItem.Title = title; contentItem.Caption = caption; contentItem.Topic = topic; contentItem.MediaTypeID = mediaTypeID; contentItem.ThresholdID = thresholdID; contentItem.RegimeID = regimeID; contentItem.MediaBlobURL = mediaBlobURL; contentItem.TimeUnitID = timeUnitID; contentItem.LicenseTypeID = licenseTypeID; contentItem.UniqueID = uniqueID; return contentItem; }