public ActionResult Download() { var profile = UnitOfWork.ProfileRepository.GetProfile(User.Identity.GetUserId()); string path = Server.MapPath("~/ExportedUserData/" + profile.Id + ".xml"); var downloadViewModel = new ProfileDownloadViewModel(profile); // Serialiserar profilen XMLSerializer.Serialize <ProfileDownloadViewModel>(downloadViewModel, path); return(RedirectToAction("IndexMe")); }
private ProfileDownloadViewModel FillProfileDownloadViewModel(ProfileModel profile) { DBConnect db = new DBConnect(); string download_query = "SELECT * FROM Download_history WHERE user_id = " + profile.id + ";"; MySqlCommand download_cmd = new MySqlCommand(download_query); ProfileDownloadViewModel download = new ProfileDownloadViewModel(); download.profile = profile; download.history = new List <DownloadHistoryModel>(1000); if (db.GetAffected(download_cmd) != 0) { foreach (DataRow row in db.GetData(download_cmd).Rows) { DownloadHistoryModel model = new DownloadHistoryModel() { user_id = (int)row["user_id"], softwareName = (string)row["softwareName"], version = (string)row["version"], id = (int)row["id"], download_date = (DateTime)row["download_date"], dl_version = (string)row["dl_version"] }; download.history.Add(model); /*download.history.Add(new DownloadHistoryModel() * { * user_id = (int)row["user_id"], * softwareName = (string)row["softwareName"], * version = (string)row["version"], * id = (int)row["id"], * download_date = (DateTime)row["download_date"], * dl_version = (string)row["dl_version"] * });*/ } } return(download); }