Beispiel #1
0
        public ActionResult Create(FormCollection form, HttpPostedFileBase uploadFile)
        {
            using (var context = new ModelContainer())
            {
                var project = new Project { ImageSource = "" };
                TryUpdateModel(project,
                               new[]
                                   {
                                       "Name",
                                       "Title",
                                       "SortOrder"
                                   });

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

                project.ImageSource = fileName;

                project.TextTop = HttpUtility.HtmlDecode(form["TextTop"]);
                project.TextBottom = HttpUtility.HtmlDecode(form["TextBottom"]);

                context.AddToProject(project);
                context.SaveChanges();
                return RedirectToAction("Index", "Home", new { Area = "", id = "projects" });
            }
        }
Beispiel #2
0
        public ProjectsModel(ModelContainer dataContext, string contentId, string projectId, bool loadContent=true) 
            : base(dataContext, contentId, projectId, loadContent)
        {

            Projects = _context.Project.ToList();
            
            if (!string.IsNullOrEmpty(projectId))
            {
                Project = _context.Project.Include("ProjectItems").First(p => p.Name == projectId);
                Title += " - " + Project.Title;
            }
        }
Beispiel #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);
 }
Beispiel #4
0
 /// <summary>
 /// Create a new Project 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="name">Initial value of the Name property.</param>
 public static Project CreateProject(global::System.Int32 id, global::System.String title, global::System.String imageSource, global::System.String name)
 {
     Project project = new Project();
     project.Id = id;
     project.Title = title;
     project.ImageSource = imageSource;
     project.Name = name;
     return project;
 }