コード例 #1
0
ファイル: FilesController.cs プロジェクト: Alex9/projectMash
        public RedirectResult uploadFile(string tagList)
        {
            foreach (string inputTagName in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[inputTagName];
                if (file.ContentLength > 0)
                {
                    string filePath = Server.MapPath("") + "\\" + file.FileName;
                    file.SaveAs(filePath);

                    Mash_v0._3.Models.File newFile = new Mash_v0._3.Models.File();

                    string email = ((FormsIdentity)System.Web.HttpContext.Current.User.Identity).Name.ToString();
                    User signedUser = db.Users.Where(user => user.email.Trim() == email).Single();

                    Project activeProject = Session["project"] as Project;

                    newFile.fileName = file.FileName;
                    newFile.idOwner = signedUser.idUser;
                    newFile.path = "Files\\" + file.FileName;
                    newFile.description = file.ContentType;
                    newFile.dateCreated = DateTime.Now;
                    newFile.dateUpdated = DateTime.Now;

                    db.Files.InsertOnSubmit(newFile);
                    db.SubmitChanges();

                    sif_ProjectFile newEntry = new sif_ProjectFile();
                    newEntry.idFile = newFile.idFile;
                    newEntry.idProject = activeProject.idProject;
                    db.sif_ProjectFiles.InsertOnSubmit(newEntry);
                    db.SubmitChanges();
                }
            }

            return Redirect("Files");
        }
コード例 #2
0
 partial void DeleteFile(File instance);
コード例 #3
0
 partial void UpdateFile(File instance);
コード例 #4
0
 partial void InsertFile(File instance);
コード例 #5
0
 /// <summary>
 /// Create a new File object.
 /// </summary>
 /// <param name="idFile">Initial value of the idFile property.</param>
 /// <param name="fileName">Initial value of the fileName property.</param>
 /// <param name="path">Initial value of the path property.</param>
 /// <param name="description">Initial value of the description property.</param>
 /// <param name="idOwner">Initial value of the idOwner property.</param>
 /// <param name="dateCreated">Initial value of the dateCreated property.</param>
 /// <param name="dateUpdated">Initial value of the dateUpdated property.</param>
 public static File CreateFile(global::System.Int32 idFile, global::System.String fileName, global::System.String path, global::System.String description, global::System.Int32 idOwner, global::System.DateTime dateCreated, global::System.DateTime dateUpdated)
 {
     File file = new File();
     file.idFile = idFile;
     file.fileName = fileName;
     file.path = path;
     file.description = description;
     file.idOwner = idOwner;
     file.dateCreated = dateCreated;
     file.dateUpdated = dateUpdated;
     return file;
 }
コード例 #6
0
 /// <summary>
 /// Deprecated Method for adding a new object to the File EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToFile(File file)
 {
     base.AddObject("File", file);
 }