Example #1
0
        public ActionResult Save_File_Data(string project, string fileName)
        // Save transferred File to database
        {
            // Use ADO instead of EF due to performance issues

            string        ADOcon       = ConfigurationManager.ConnectionStrings["ADOLucroAnalyzer"].ConnectionString;
            SqlConnection DbConnection = new SqlConnection(ADOcon);

            DbConnection.Open();

            DB_Context db     = new DB_Context();
            CSVFile    myData = new CSVFile();

            myData = UploadToObject(project, fileName);

            var projectList = db.Project.ToList();

            // Get the ProjectId for the Project Name given.

            int myProjectId = (from projItem in projectList
                               where projItem.ProjectName == project && projItem.UserId == User.Identity.GetUserId()
                               select projItem.ProjectId).FirstOrDefault();

            // Save the Properties and DataNames in the database and return their corresponding Id's (key values9 from the database model
            List <List <int> > myIDList = FillNames(myProjectId, myData.NameList, myData.TypeList);

            ProjectData myProject = new ProjectData();

            // SHow that the project is in the update status (used to show a text in the project list oin the View)
            myProject.SetProjectstatus(myProjectId, "U");

            // Fill all values for properties and datanames in the database
            myProject.FillValues(ADOcon, context: db, myProjectID: myProjectId, myIDList: myIDList, myTypeList: myData.TypeList, myValueList: myData.ValueList);

            db.SaveChanges();
            db.Dispose();
            DbConnection.Close();

            // Show project List
            return(RedirectToAction("../Projects/ProjectList"));
        }