Beispiel #1
0
 /// <summary>
 /// Create a new ProjectItem object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="title">Initial value of the Title property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 /// <param name="projectId">Initial value of the ProjectId property.</param>
 public static ProjectItem CreateProjectItem(global::System.Int32 id, global::System.String title, global::System.String imageSource, global::System.Int32 projectId)
 {
     ProjectItem projectItem = new ProjectItem();
     projectItem.Id = id;
     projectItem.Title = title;
     projectItem.ImageSource = imageSource;
     projectItem.ProjectId = projectId;
     return projectItem;
 }
Beispiel #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProjectItem EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjectItem(ProjectItem projectItem)
 {
     base.AddObject("ProjectItem", projectItem);
 }
Beispiel #3
0
        public ActionResult CreateProjectItem(FormCollection form, HttpPostedFileBase uploadFile)
        {
            using (var context = new ModelContainer())
            {
                int projectId = Convert.ToInt32(form["ProjectId"]);
                var project = context.Project.First(p => p.Id == projectId);

                var projectItem = new ProjectItem();
                TryUpdateModel(projectItem,
                               new[]
                                   {
                                       "Title",
                                       "SortOrder"
                                   });

                string fileName = IOHelper.GetUniqueFileName("~/Content/Images", uploadFile.FileName);
                string filePath = Server.MapPath("~/Content/Images");
                filePath = Path.Combine(filePath, fileName);
                uploadFile.SaveAs(filePath);

                GraphicsHelper.SaveCachedImage("~/Content/Images", fileName, "mainView",ScaleMode.Corp);
                GraphicsHelper.SaveCachedImage("~/Content/Images", fileName, "galleryThumbnail", ScaleMode.Corp);

                projectItem.ImageSource = fileName;

                project.ProjectItems.Add(projectItem);
                context.SaveChanges();

                return RedirectToAction("Index", "Projects", new { Area = "", id = project.Name });
            }
        }