Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ProjectImage EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProjectImage(ProjectImage projectImage)
 {
     base.AddObject("ProjectImage", projectImage);
 }
Exemplo n.º 2
0
        public ActionResult AddImageToProject1(int projectId)
        {
            using (var context = new SiteContainer())
            {
                var project = context.Project.First(p => p.Id == projectId);

                for (int i = 0; i < Request.Files.Count; i++)
                {
                    var file = Request.Files[i];
                    if (file == null) continue;

                    var pi = new ProjectImage();
                    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName);
                    string filePath = Server.MapPath("~/Content/Images");
                    filePath = Path.Combine(filePath, fileName);
                    file.SaveAs(filePath);
                    pi.ImageSource = fileName;
                    project.ProjectImages.Add(pi);
                    context.SaveChanges();
                }



                //if (fileUpload != null)
                //{
                //    var pi = new ProjectImage();
                //    string fileName = IOHelper.GetUniqueFileName("~/Content/Images", fileUpload.FileName);
                //    string filePath = Server.MapPath("~/Content/Images");
                //    filePath = Path.Combine(filePath, fileName);
                //    fileUpload.SaveAs(filePath);
                //    pi.ImageSource = fileName;
                //    project.ProjectImages.Add(pi);
                //    context.SaveChanges();
                //}
                return RedirectToAction("Projects", "Home", new { area = "", id = project.Name });
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new ProjectImage object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="imageSource">Initial value of the ImageSource property.</param>
 /// <param name="projectId">Initial value of the ProjectId property.</param>
 /// <param name="mainImage">Initial value of the MainImage property.</param>
 public static ProjectImage CreateProjectImage(global::System.Int32 id, global::System.String imageSource, global::System.Int32 projectId, global::System.Boolean mainImage)
 {
     ProjectImage projectImage = new ProjectImage();
     projectImage.Id = id;
     projectImage.ImageSource = imageSource;
     projectImage.ProjectId = projectId;
     projectImage.MainImage = mainImage;
     return projectImage;
 }