コード例 #1
0
ファイル: Model.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <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;
 }
コード例 #2
0
ファイル: Model.Designer.cs プロジェクト: fathurxzz/aleqx
 /// <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);
 }
コード例 #3
0
ファイル: ProjectController.cs プロジェクト: fathurxzz/aleqx
        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 });
            }
        }