Ejemplo n.º 1
0
 public ActionResult Create(FormCollection form, HttpPostedFileBase fileUpload, Project model)
 {
     try
     {
         using (var context = new SiteContainer())
         {
             var content = context.Content.First(c => c.Id == model.ContentId);
             var project = new Project();
             TryUpdateModel(project, new[] { "Name", "Title", "DescriptionTitle", "SortOrder" });
             project.Description = HttpUtility.HtmlDecode(form["Description"]);
             project.VideoSource = form["VideoSource"];
             if (fileUpload != null)
             {
                 string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                 string filePath = Server.MapPath("~/Content/Images");
                 filePath = Path.Combine(filePath, fileName);
                 fileUpload.SaveAs(filePath);
                 project.ImageSource = fileName;
             }
             content.Projects.Add(project);
             //context.AddToProject(project);
             context.SaveChanges();
             return RedirectToAction("Projects", "Home", new { area = "", id = project.Name });
         }
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create a new Project object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="sortOrder">Initial value of the SortOrder property.</param>
 /// <param name="contentId">Initial value of the ContentId property.</param>
 public static Project CreateProject(global::System.Int32 id, global::System.String name, global::System.String title, global::System.Int32 sortOrder, global::System.Int32 contentId)
 {
     Project project = new Project();
     project.Id = id;
     project.Name = name;
     project.Title = title;
     project.SortOrder = sortOrder;
     project.ContentId = contentId;
     return project;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Project EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProject(Project project)
 {
     base.AddObject("Project", project);
 }