- Timestamp:
- 05/27/11 19:09:49 (14 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AdminController.cs ¶
r6290 r6317 13 13 14 14 namespace HLWebOKBAdminPlugin.Controllers { 15 16 17 15 public class AdminController : Controller { 16 private AdministrationServiceClient CertificateValidator() { 17 AdministrationServiceClient asc = new AdministrationServiceClient(); 18 18 19 20 21 19 asc.ClientCredentials.UserName.UserName = HttpContext.Session["Username"].ToString(); 20 asc.ClientCredentials.UserName.Password = HttpContext.Session["Password"].ToString(); 21 asc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 22 22 23 24 23 return asc; 24 }//CertificateValidator 25 25 26 27 28 26 public ActionResult Index() { 27 return View(); 28 }// ActionResult Index 29 29 30 public ActionResult Menu() { 31 32 return View(); 33 }//ActionResult Men 30 public ActionResult Menu() { 34 31 35 public ActionResult AlgorithmClass() {36 AdministrationServiceClient adminCLient = Admin.GetClientFactory();32 return View(); 33 }//ActionResult Men 37 34 38 AdminModel am = new AdminModel(); 39 Session["SelectedSubMenu"] = "AlgorithmClass"; 40 var algorithmClasses = am.AlgorithmClassProp; 35 public ActionResult AlgorithmClass() { 36 AdministrationServiceClient adminCLient = Admin.GetClientFactory(); 41 37 42 return View(algorithmClasses); 43 }//ActionResult AlgorithmClassC:\SYS\profiles\schwgh\Desktop\WebApplication\MVC2\HLWebOKBAdminPlugin\Views\Admin\Algorithm.aspx 38 AdminModel am = new AdminModel(); 39 Session["SelectedSubMenu"] = "AlgorithmClass"; 40 var algorithmClasses = am.AlgorithmClassProp; 44 41 45 public ActionResult Algorithm() {46 AdministrationServiceClient adminCLient = Admin.GetClientFactory();42 return View(algorithmClasses); 43 }//ActionResult AlgorithmClassC:\SYS\profiles\schwgh\Desktop\WebApplication\MVC2\HLWebOKBAdminPlugin\Views\Admin\Algorithm.aspx 47 44 48 AdminModel am = new AdminModel(); 49 Session["SelectedSubMenu"] = "Algorithm"; 50 var algorithm = am.AlgorithmsGetAll(); 45 public ActionResult Algorithm() { 46 AdministrationServiceClient adminCLient = Admin.GetClientFactory(); 51 47 52 return View(algorithm); 53 }//Algorithm 48 AdminModel am = new AdminModel(); 49 Session["SelectedSubMenu"] = "Algorithm"; 50 var algorithm = am.AlgorithmsGetAll(); 54 51 55 public ActionResult ProblemClass() {56 AdministrationServiceClient adminCLient = Admin.GetClientFactory();52 return View(algorithm); 53 }//Algorithm 57 54 58 AdminModel am = new AdminModel(); 59 Session["SelectedSubMenu"] = "ProblemClass"; 60 var problemClasses = am.ProblemClassGetAll(); 55 public ActionResult ProblemClass() { 56 AdministrationServiceClient adminCLient = Admin.GetClientFactory(); 61 57 62 return View(problemClasses); 63 }//ProblemClass 58 AdminModel am = new AdminModel(); 59 Session["SelectedSubMenu"] = "ProblemClass"; 60 var problemClasses = am.ProblemClassGetAll(); 64 61 65 public ActionResult Problem() {66 AdministrationServiceClient adminCLient = Admin.GetClientFactory();62 return View(problemClasses); 63 }//ProblemClass 67 64 68 AdminModel am = new AdminModel(); 69 Session["SelectedSubMenu"] = "Problem"; 70 var problem = am.ProblemsGetAll(); 65 public ActionResult Problem() { 66 AdministrationServiceClient adminCLient = Admin.GetClientFactory(); 71 67 72 return View(problem); 73 }//Problem 68 AdminModel am = new AdminModel(); 69 Session["SelectedSubMenu"] = "Problem"; 70 var problem = am.ProblemsGetAll(); 74 71 75 public ActionResult OKBNamedItemList_Test() { 76 return View(); 77 }//Problem 72 return View(problem); 73 }//Problem 78 74 79 } 75 public ActionResult OKBNamedItemList_Test() { 76 return View(); 77 }//Problem 78 79 } 80 80 } -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmClassController.cs ¶
r6290 r6317 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 8 9 namespace HLWebOKBAdminPlugin.Controllers 10 { 11 public class AlgorithmClassController : Controller 12 { 13 // 14 // GET: /AlgorithmClass/ 9 namespace HLWebOKBAdminPlugin.Controllers { 10 public class AlgorithmClassController : Controller { 11 // 12 // GET: /AlgorithmClass/ 15 13 16 14 public ActionResult Index() { 17 15 18 19 20 21 16 Session["SelectedSubMenu"] = "AlgorithmClass"; 17 AlgorithmClassModel acm = new AlgorithmClassModel(); 18 return View(acm); 19 }//Index 22 20 23 24 25 21 public ActionResult Detail(long? id) { 22 Session["SelectedSubMenu"] = "AlgorithmClass"; 23 AlgorithmClassModel acm = new AlgorithmClassModel(); 26 24 27 28 29 30 31 32 25 if (id == null) 26 acm.AlgorithmClass = new AlgorithmClass(); 27 else 28 acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 29 return View(acm); 30 }//Detail 33 31 34 35 36 37 38 39 32 /// <summary> 33 /// Controller for Index View 34 /// </summary> 35 /// <returns></returns> 36 public ActionResult Delete(long? id) { 37 Session["SelectedSubMenu"] = "AlgorithmClass"; 40 38 41 42 43 44 45 46 39 AlgorithmClassModel acm = new AlgorithmClassModel(); 40 if (id != 0) { 41 acm.DeleteAlgorithmClass((long)id); 42 } 43 return View("Index", acm); 44 }//Delete 47 45 48 49 50 51 52 53 54 55 46 /// <summary> 47 /// Controller for Detail View 48 /// </summary> 49 /// <returns></returns> 50 public ActionResult SaveChanges(FormCollection collection) { 51 long algorithmClassId = long.Parse(collection.Get("AlgorithmClassId")); 52 String algorithmClassName = collection.Get("AlgorithmClassName"); 53 String algorithmClassDescription = collection.Get("AlgorithmClassDescription"); 56 54 57 58 59 60 55 // Later, we will get the runs from the session ... 56 AlgorithmClassModel acm = new AlgorithmClassModel(); 57 if (algorithmClassId != 0) 58 acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals(algorithmClassId)).FirstOrDefault(); 61 59 62 63 60 acm.AlgorithmClass.Name = algorithmClassName; 61 acm.AlgorithmClass.Description = algorithmClassDescription; 64 62 65 63 acm.SaveAlgorithmClass(acm.AlgorithmClass); 66 64 67 68 65 return View("Index", acm); 66 }//SaveChanges 69 67 70 71 72 73 74 75 76 77 78 79 68 /// <summary> 69 /// Controller for Index View 70 /// </summary> 71 /// <returns></returns> 72 public ActionResult SortAsc() { 73 Session["SelectedSubMenu"] = "AlgorithmClass"; 74 AlgorithmClassModel acm = new AlgorithmClassModel(); 75 acm.AlgorithmClasses = acm.AlgorithmClasses.OrderBy(x => x.Name).ToList<AlgorithmClass>(); 76 return View("Index", acm); 77 } 80 78 81 82 83 84 85 86 87 79 /// <summary> 80 /// Controller for Index View 81 /// </summary> 82 /// <returns></returns> 83 public ActionResult SortDesc() { 84 Session["SelectedSubMenu"] = "AlgorithmClass"; 85 AlgorithmClassModel acm = new AlgorithmClassModel(); 88 86 89 90 91 92 93 94 87 IOrderedEnumerable<AlgorithmClass> acmOrderedList = acm.AlgorithmClasses.OrderByDescending(x => x.Name); 88 IList<AlgorithmClass> acmList = new List<AlgorithmClass>(); 89 foreach (var item in acmOrderedList) { 90 acmList.Add(item); 91 } 92 acm.AlgorithmClasses = acmList; 95 93 96 97 98 99 94 // this should be the right code 95 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 96 return View("Index", acm); 97 } 100 98 101 99 } 102 100 } 103 101 104 102 -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmController.cs ¶
r6283 r6317 8 8 using System.IO; 9 9 10 namespace HLWebOKBAdminPlugin.Controllers 11 { 10 namespace HLWebOKBAdminPlugin.Controllers { 11 /// <summary> 12 /// Controller for Algorithm Submenu 13 /// </summary> 14 public class AlgorithmController : Controller { 12 15 /// <summary> 13 /// Controller for Algorithm Submenu16 /// Controller for Index View 14 17 /// </summary> 15 public class AlgorithmController : Controller 16 { 17 /// <summary> 18 /// Controller for Index View 19 /// </summary> 20 /// <returns></returns> 21 public ActionResult Index() 22 { 23 Session["SelectedSubMenu"] = "Algorithm"; 24 AlgorithmModel pm = new AlgorithmModel(); 25 return View(pm); 26 } 18 /// <returns></returns> 19 public ActionResult Index() { 20 Session["SelectedSubMenu"] = "Algorithm"; 21 AlgorithmModel pm = new AlgorithmModel(); 22 return View(pm); 23 } 27 24 28 /// <summary> 29 /// Controller for Index View 30 /// </summary> 31 /// <returns></returns> 32 public ActionResult SortAsc() { 33 Session["SelectedSubMenu"] = "Algorithm"; 34 AlgorithmModel pm = new AlgorithmModel(); 35 pm.Algorithms = pm.Algorithms.OrderBy(x => x.Name).ToList<Algorithm>(); 36 return View("Index",pm); 25 /// <summary> 26 /// Controller for Index View 27 /// </summary> 28 /// <returns></returns> 29 public ActionResult SortAsc() { 30 Session["SelectedSubMenu"] = "Algorithm"; 31 AlgorithmModel pm = new AlgorithmModel(); 32 pm.Algorithms = pm.Algorithms.OrderBy(x => x.Name).ToList<Algorithm>(); 33 return View("Index", pm); 34 } 35 36 /// <summary> 37 /// Controller for Index View 38 /// </summary> 39 /// <returns></returns> 40 public ActionResult SortDesc() { 41 Session["SelectedSubMenu"] = "Algorithm"; 42 AlgorithmModel pm = new AlgorithmModel(); 43 pm.Algorithms = pm.Algorithms.OrderByDescending(x => x.Name).ToArray<Algorithm>(); 44 return View("Index", pm); 45 } 46 /// <summary> 47 /// Controller for Detail View 48 /// </summary> 49 /// <param name="p"></param> 50 /// <returns></returns> 51 public ActionResult Detail(long? id) { 52 Session["SelectedSubMenu"] = "Algorithm"; 53 // We use here the AlgorithmMode, but I think 54 // we can also use the Algorithm class. (?) 55 AlgorithmModel pm = new AlgorithmModel(); 56 if (id == null) 57 pm.Algorithm = new Algorithm(); 58 else 59 pm.Algorithm = (Algorithm)pm.Algorithms.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 60 return View(pm); 61 } 62 63 /// <summary> 64 /// Controller for Index View 65 /// </summary> 66 /// <returns></returns> 67 public ActionResult Delete(long id) { 68 Session["SelectedSubMenu"] = "Algorithm"; 69 // We use here the AlgorithmMode, but I think 70 // we can also use the Algorithm class. (?) 71 AlgorithmModel pm = new AlgorithmModel(); 72 if (id != 0) { 73 pm.DeleteAlgorithm(id); 74 } 75 return View("Index", pm); 76 } 77 78 public ActionResult UploadFile(FormCollection collection) { 79 Session["SelectedSubMenu"] = "Algorithm"; 80 81 long algorithmId = long.Parse(collection.Get("AlgorithmId")); 82 83 AlgorithmModel pm = new AlgorithmModel(); 84 85 foreach (string inputTagName in Request.Files) { 86 HttpPostedFileBase file = Request.Files[inputTagName]; 87 if (file.ContentLength > 0) { 88 // maybe for storage on server 89 //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName)); 90 if (file.InputStream.CanRead) { 91 //file length 92 int fileLength = file.ContentLength; 93 94 //bytearray 95 byte[] data = new byte[fileLength]; 96 97 //initialize input stream 98 Stream dataStream = file.InputStream; 99 100 //read file into byte array 101 dataStream.Read(data, 0, fileLength); 102 103 //save data 104 pm.UpdateAlgorithmData(algorithmId, data); 105 }//if 37 106 } 107 }//foreach 38 108 39 /// <summary> 40 /// Controller for Index View 41 /// </summary> 42 /// <returns></returns> 43 public ActionResult SortDesc() { 44 Session["SelectedSubMenu"] = "Algorithm"; 45 AlgorithmModel pm = new AlgorithmModel(); 46 pm.Algorithms = pm.Algorithms.OrderByDescending(x => x.Name).ToArray<Algorithm>(); 47 return View("Index",pm); 48 } 49 /// <summary> 50 /// Controller for Detail View 51 /// </summary> 52 /// <param name="p"></param> 53 /// <returns></returns> 54 public ActionResult Detail(long? id) 55 { 56 Session["SelectedSubMenu"] = "Algorithm"; 57 // We use here the AlgorithmMode, but I think 58 // we can also use the Algorithm class. (?) 59 AlgorithmModel pm = new AlgorithmModel(); 60 if(id == null) 61 pm.Algorithm = new Algorithm(); 62 else 63 pm.Algorithm = (Algorithm)pm.Algorithms.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 64 return View(pm); 65 } 109 return View("Index", pm); 110 }//UploadFile 66 111 67 /// <summary> 68 /// Controller for Index View 69 /// </summary> 70 /// <returns></returns> 71 public ActionResult Delete(long id) { 72 Session["SelectedSubMenu"] = "Algorithm"; 73 // We use here the AlgorithmMode, but I think 74 // we can also use the Algorithm class. (?) 75 AlgorithmModel pm = new AlgorithmModel(); 76 if(id != 0) { 77 pm.DeleteAlgorithm(id); 78 } 79 return View("Index", pm); 80 } 112 /// <summary> 113 /// Controller for Detail View 114 /// </summary> 115 /// <returns></returns> 116 public ActionResult SaveChanges(FormCollection collection) { 117 long algorithmId = long.Parse(collection.Get("AlgorithmId")); 118 String algorithmName = collection.Get("AlgorithmName"); 119 String algorithmDescription = collection.Get("AlgorithmDescription"); 120 String algorithmDataTypeName = collection.Get("AlgorithmDataTypeName"); 121 long algorithmClassId = long.Parse(collection.Get("AlgorithmClassId")); 122 long platformId = long.Parse(collection.Get("PlatformId")); 81 123 82 public ActionResult UploadFile(FormCollection collection) { 83 Session["SelectedSubMenu"] = "Algorithm"; 124 // Later, we will get the runs from the session ... 125 AlgorithmModel pm = new AlgorithmModel(); 126 if (algorithmId != 0) 127 pm.Algorithm = (Algorithm)pm.Algorithms.Where(x => x.Id.Equals(algorithmId)).FirstOrDefault(); 84 128 85 long algorithmId = long.Parse(collection.Get("AlgorithmId")); 129 pm.Algorithm.Name = algorithmName; 130 pm.Algorithm.Description = algorithmDescription; 131 pm.Algorithm.DataTypeName = algorithmDataTypeName; 132 pm.Algorithm.DataTypeTypeName = ""; 133 pm.Algorithm.AlgorithmClassId = algorithmClassId; 134 pm.Algorithm.PlatformId = platformId; 86 135 87 AlgorithmModel pm = new AlgorithmModel();136 pm.SaveAlgorithm(pm.Algorithm); 88 137 89 foreach (string inputTagName in Request.Files) { 90 HttpPostedFileBase file = Request.Files[inputTagName]; 91 if (file.ContentLength > 0) { 92 // maybe for storage on server 93 //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName)); 94 if (file.InputStream.CanRead) { 95 //file length 96 int fileLength = file.ContentLength; 97 98 //bytearray 99 byte[] data = new byte[fileLength]; 100 101 //initialize input stream 102 Stream dataStream = file.InputStream; 103 104 //read file into byte array 105 dataStream.Read(data, 0, fileLength); 106 107 //save data 108 pm.UpdateAlgorithmData(algorithmId, data); 109 }//if 110 } 111 }//foreach 112 113 return View("Index", pm); 114 }//UploadFile 115 116 /// <summary> 117 /// Controller for Detail View 118 /// </summary> 119 /// <returns></returns> 120 public ActionResult SaveChanges(FormCollection collection) { 121 long algorithmId = long.Parse(collection.Get("AlgorithmId")); 122 String algorithmName = collection.Get("AlgorithmName"); 123 String algorithmDescription = collection.Get("AlgorithmDescription"); 124 String algorithmDataTypeName = collection.Get("AlgorithmDataTypeName"); 125 long algorithmClassId = long.Parse(collection.Get("AlgorithmClassId")); 126 long platformId = long.Parse(collection.Get("PlatformId")); 127 128 // Later, we will get the runs from the session ... 129 AlgorithmModel pm = new AlgorithmModel(); 130 if(algorithmId != 0) 131 pm.Algorithm = (Algorithm)pm.Algorithms.Where(x => x.Id.Equals(algorithmId)).FirstOrDefault(); 132 133 pm.Algorithm.Name = algorithmName; 134 pm.Algorithm.Description = algorithmDescription; 135 pm.Algorithm.DataTypeName = algorithmDataTypeName; 136 pm.Algorithm.DataTypeTypeName = ""; 137 pm.Algorithm.AlgorithmClassId = algorithmClassId; 138 pm.Algorithm.PlatformId = platformId; 139 140 pm.SaveAlgorithm(pm.Algorithm); 141 142 return View("Index",pm); 143 } 144 } 138 return View("Index", pm); 139 } 140 } 145 141 } -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/HomeController.cs ¶
r6283 r6317 5 5 using System.Web.Mvc; 6 6 7 namespace HLWebOKBAdminPlugin.Controllers 8 { 9 [HandleError] 10 public class HomeController : Controller 11 { 12 // 13 // GET: /Home/ 7 namespace HLWebOKBAdminPlugin.Controllers { 8 [HandleError] 9 public class HomeController : Controller { 10 // 11 // GET: /Home/ 14 12 15 public ActionResult Index() 16 { 17 ViewData["Message"] = "Welcome to ASP.NET MVC!"; 18 return View(); 19 } 13 public ActionResult Index() { 14 ViewData["Message"] = "Welcome to ASP.NET MVC!"; 15 return View(); 16 } 20 17 21 22 23 18 public ActionResult About() { 19 return View(); 20 } 24 21 25 22 } 26 23 } -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/PlatformController.cs ¶
r6313 r6317 7 7 using HLWebOKBAdminPlugin.OKBAdministrationService; 8 8 9 namespace HLWebOKBAdminPlugin.Controllers 10 { 11 public class PlatformController : Controller 12 { 13 // 14 // GET: /Platform/ 9 namespace HLWebOKBAdminPlugin.Controllers { 10 public class PlatformController : Controller { 11 // 12 // GET: /Platform/ 15 13 16 public ActionResult Index() 17 { 18 Session["SelectedSubMenu"] = "Platform"; 19 PlatformModel plm = new PlatformModel(); 20 return View(plm); 21 }//Index 14 public ActionResult Index() { 15 Session["SelectedSubMenu"] = "Platform"; 16 PlatformModel plm = new PlatformModel(); 17 return View(plm); 18 }//Index 22 19 23 20 24 25 26 21 public ActionResult Detail(long? id) { 22 Session["SelectedSubMenu"] = "Platform"; 23 PlatformModel plm = new PlatformModel(); 27 24 28 29 30 31 32 33 25 if (id == null) 26 plm.Platform = new Platform(); 27 else 28 plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 29 return View(plm); 30 }//Detail 34 31 35 36 32 public ActionResult Delete(long? id) { 33 Session["SelectedSubMenu"] = "Platform"; 37 34 38 39 40 41 42 43 35 PlatformModel plm = new PlatformModel(); 36 if (id != 0) { 37 plm.DeletePlatform((long)id); 38 } 39 return View("Index", plm); 40 }//Delete 44 41 45 46 47 48 42 public ActionResult SaveChanges(FormCollection collection) { 43 long platformId = long.Parse(collection.Get("PlatformId")); 44 String platformName = collection.Get("PlatformName"); 45 String platformDescription = collection.Get("PlatformDescription"); 49 46 50 51 52 53 47 // Later, we will get the runs from the session ... 48 PlatformModel plm = new PlatformModel(); 49 if (platformId != 0) 50 plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals(platformId)).FirstOrDefault(); 54 51 55 56 52 plm.Platform.Name = platformName; 53 plm.Platform.Description = platformDescription; 57 54 58 55 plm.SavePlatform(plm.Platform); 59 56 60 61 57 return View("Index", plm); 58 }//SaveChanges 62 59 63 64 65 66 67 68 60 public ActionResult SortAsc() { 61 Session["SelectedSubMenu"] = "Platform"; 62 PlatformModel plm = new PlatformModel(); 63 plm.Platforms = plm.Platforms.OrderBy(x => x.Name).ToList<Platform>(); 64 return View("Index", plm); 65 } 69 66 70 71 72 73 74 75 76 67 /// <summary> 68 /// Controller for Index View 69 /// </summary> 70 /// <returns></returns> 71 public ActionResult SortDesc() { 72 Session["SelectedSubMenu"] = "Platform"; 73 PlatformModel plm = new PlatformModel(); 77 74 78 79 80 81 82 83 75 IOrderedEnumerable<Platform> plmOrderedList = plm.Platforms.OrderByDescending(x => x.Name); 76 IList<Platform> plmList = new List<Platform>(); 77 foreach (var item in plmOrderedList) { 78 plmList.Add(item); 79 } 80 plm.Platforms = plmList; 84 81 85 // this should be the right code 86 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 87 return View("Index", plm); 88 } 82 // this should be the right code 83 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 84 return View("Index", plm); 89 85 } 86 } 90 87 } -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemClassController.cs ¶
r6283 r6317 8 8 9 9 10 namespace HLWebOKBAdminPlugin.Controllers 11 { 12 // <summary> 13 // Controller for ProblemClass Submenu 14 // </summary> 15 public class ProblemClassController : Controller 16 { 17 // 18 // GET: /ProblemClass/ 10 namespace HLWebOKBAdminPlugin.Controllers { 11 // <summary> 12 // Controller for ProblemClass Submenu 13 // </summary> 14 public class ProblemClassController : Controller { 15 // 16 // GET: /ProblemClass/ 19 17 20 public ActionResult Index() 21 { 22 Session["SelectedSubMenu"] = "ProblemClass"; 23 ProblemClassModel pcm = new ProblemClassModel(); 24 return View(pcm); 25 }//Index 18 public ActionResult Index() { 19 Session["SelectedSubMenu"] = "ProblemClass"; 20 ProblemClassModel pcm = new ProblemClassModel(); 21 return View(pcm); 22 }//Index 26 23 27 28 29 24 public ActionResult Detail(long? id) { 25 Session["SelectedSubMenu"] = "ProblemClass"; 26 ProblemClassModel pcm = new ProblemClassModel(); 30 27 31 32 33 34 35 36 28 if (id == null) 29 pcm.ProblemClass = new ProblemClass(); 30 else 31 pcm.ProblemClass = (ProblemClass)pcm.ProblemClasses.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 32 return View(pcm); 33 }//Detail 37 34 38 39 40 41 42 43 35 /// <summary> 36 /// Controller for Index View 37 /// </summary> 38 /// <returns></returns> 39 public ActionResult Delete(long? id) { 40 Session["SelectedSubMenu"] = "ProblemClass"; 44 41 45 46 47 48 49 50 42 ProblemClassModel pcm = new ProblemClassModel(); 43 if (id != 0) { 44 pcm.DeleteProblemClass((long)id); 45 } 46 return View("Index", pcm); 47 }//Delete 51 48 52 53 54 55 56 57 58 59 49 /// <summary> 50 /// Controller for Detail View 51 /// </summary> 52 /// <returns></returns> 53 public ActionResult SaveChanges(FormCollection collection) { 54 long problemClassId = long.Parse(collection.Get("ProblemClassId")); 55 String problemClassName = collection.Get("ProblemClassName"); 56 String problemClassDescription = collection.Get("ProblemClassDescription"); 60 57 61 62 63 64 58 // Later, we will get the runs from the session ... 59 ProblemClassModel pcm = new ProblemClassModel(); 60 if (problemClassId != 0) 61 pcm.ProblemClass = (ProblemClass)pcm.ProblemClasses.Where(x => x.Id.Equals(problemClassId)).FirstOrDefault(); 65 62 66 67 63 pcm.ProblemClass.Name = problemClassName; 64 pcm.ProblemClass.Description = problemClassDescription; 68 65 69 66 pcm.SaveProblemClass(pcm.ProblemClass); 70 67 71 72 68 return View("Index", pcm); 69 }//SaveChanges 73 70 74 75 76 77 78 79 80 81 82 83 71 /// <summary> 72 /// Controller for Index View 73 /// </summary> 74 /// <returns></returns> 75 public ActionResult SortAsc() { 76 Session["SelectedSubMenu"] = "ProblemClass"; 77 ProblemClassModel pcm = new ProblemClassModel(); 78 pcm.ProblemClasses = pcm.ProblemClasses.OrderBy(x => x.Name).ToList<ProblemClass>(); 79 return View("Index", pcm); 80 } 84 81 85 86 87 88 89 90 91 82 /// <summary> 83 /// Controller for Index View 84 /// </summary> 85 /// <returns></returns> 86 public ActionResult SortDesc() { 87 Session["SelectedSubMenu"] = "ProblemClass"; 88 ProblemClassModel pcm = new ProblemClassModel(); 92 89 93 94 95 96 97 98 90 IOrderedEnumerable<ProblemClass> pcmOrderedList = pcm.ProblemClasses.OrderByDescending(x => x.Name); 91 IList<ProblemClass> pcmList = new List<ProblemClass>(); 92 foreach (var item in pcmOrderedList) { 93 pcmList.Add(item); 94 } 95 pcm.ProblemClasses = pcmList; 99 96 100 101 102 103 97 // this should be the right code 98 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 99 return View("Index", pcm); 100 } 104 101 105 102 } 106 103 } -
TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs ¶
r6283 r6317 8 8 using System.IO; 9 9 10 namespace HLWebOKBAdminPlugin.Controllers 11 { 10 namespace HLWebOKBAdminPlugin.Controllers { 11 /// <summary> 12 /// Controller for Problem Submenu 13 /// </summary> 14 public class ProblemController : Controller { 12 15 /// <summary> 13 /// Controller for Problem Submenu16 /// Controller for Index View 14 17 /// </summary> 15 public class ProblemController : Controller 16 { 17 /// <summary> 18 /// Controller for Index View 19 /// </summary> 20 /// <returns></returns> 21 public ActionResult Index() 22 { 23 Session["SelectedSubMenu"] = "Problem"; 24 ProblemModel pm = new ProblemModel(); 25 return View(pm); 26 } 18 /// <returns></returns> 19 public ActionResult Index() { 20 Session["SelectedSubMenu"] = "Problem"; 21 ProblemModel pm = new ProblemModel(); 22 return View(pm); 23 } 27 24 28 /// <summary> 29 /// Controller for Index View 30 /// </summary> 31 /// <returns></returns> 32 public ActionResult SortAsc() { 33 Session["SelectedSubMenu"] = "Problem"; 34 ProblemModel pm = new ProblemModel(); 35 pm.Problems = pm.Problems.OrderBy(x => x.Name).ToList<Problem>(); 36 return View("Index",pm); 25 /// <summary> 26 /// Controller for Index View 27 /// </summary> 28 /// <returns></returns> 29 public ActionResult SortAsc() { 30 Session["SelectedSubMenu"] = "Problem"; 31 ProblemModel pm = new ProblemModel(); 32 pm.Problems = pm.Problems.OrderBy(x => x.Name).ToList<Problem>(); 33 return View("Index", pm); 34 } 35 36 /// <summary> 37 /// Controller for Index View 38 /// </summary> 39 /// <returns></returns> 40 public ActionResult SortDesc() { 41 Session["SelectedSubMenu"] = "Problem"; 42 ProblemModel pm = new ProblemModel(); 43 44 //this is code for testing sortorder 45 IOrderedEnumerable<Problem> test = pm.Problems.OrderByDescending(x => x.Name); 46 IList<Problem> test2 = new List<Problem>(); 47 foreach (var item in test) { 48 test2.Add(item); 49 } 50 pm.Problems = test2; 51 52 // this should be the right code 53 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 54 return View("Index", pm); 55 } 56 /// <summary> 57 /// Controller for Detail View 58 /// </summary> 59 /// <param name="p"></param> 60 /// <returns></returns> 61 public ActionResult Detail(long? id) { 62 Session["SelectedSubMenu"] = "Problem"; 63 // We use here the ProblemMode, but I think 64 // we can also use the Problem class. (?) 65 ProblemModel pm = new ProblemModel(); 66 if (id == null) 67 pm.Problem = new Problem(); 68 else 69 pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 70 return View(pm); 71 } 72 73 /// <summary> 74 /// Controller for Index View 75 /// </summary> 76 /// <returns></returns> 77 public ActionResult Delete(long id) { 78 Session["SelectedSubMenu"] = "Problem"; 79 // We use here the ProblemMode, but I think 80 // we can also use the Problem class. (?) 81 ProblemModel pm = new ProblemModel(); 82 if (id != 0) { 83 pm.DeleteProblem(id); 84 } 85 return View("Index", pm); 86 } 87 88 public ActionResult UploadFile(FormCollection collection) { 89 Session["SelectedSubMenu"] = "Problem"; 90 91 long problemId = long.Parse(collection.Get("ProblemId")); 92 93 ProblemModel pm = new ProblemModel(); 94 95 foreach (string inputTagName in Request.Files) { 96 HttpPostedFileBase file = Request.Files[inputTagName]; 97 if (file.ContentLength > 0) { 98 // maybe for storage on server 99 //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName)); 100 if (file.InputStream.CanRead) { 101 //file length 102 int fileLength = file.ContentLength; 103 104 //bytearray 105 byte[] data = new byte[fileLength]; 106 107 //initialize input stream 108 Stream dataStream = file.InputStream; 109 110 //read file into byte array 111 dataStream.Read(data, 0, fileLength); 112 113 //save data 114 pm.UpdateProblemData(problemId, data); 115 }//if 37 116 } 117 }//foreach 38 118 39 /// <summary> 40 /// Controller for Index View 41 /// </summary> 42 /// <returns></returns> 43 public ActionResult SortDesc() { 44 Session["SelectedSubMenu"] = "Problem"; 45 ProblemModel pm = new ProblemModel(); 119 return View("Index", pm); 120 }//UploadFile 46 121 47 //this is code for testing sortorder 48 IOrderedEnumerable<Problem> test = pm.Problems.OrderByDescending(x => x.Name); 49 IList<Problem> test2 = new List<Problem>(); 50 foreach(var item in test) { 51 test2.Add(item); 52 } 53 pm.Problems = test2; 122 /// <summary> 123 /// Controller for Detail View 124 /// </summary> 125 /// <returns></returns> 126 public ActionResult SaveChanges(FormCollection collection) { 127 long problemId = long.Parse(collection.Get("ProblemId")); 128 String problemName = collection.Get("ProblemName"); 129 String problemDescription = collection.Get("ProblemDescription"); 130 String problemDataTypeName = collection.Get("ProblemDataTypeName"); 131 long problemClassId = long.Parse(collection.Get("ProblemClassId")); 132 long platformId = long.Parse(collection.Get("PlatformId")); 54 133 55 // this should be the right code 56 //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>(); 57 return View("Index", pm); 58 } 59 /// <summary> 60 /// Controller for Detail View 61 /// </summary> 62 /// <param name="p"></param> 63 /// <returns></returns> 64 public ActionResult Detail(long? id) 65 { 66 Session["SelectedSubMenu"] = "Problem"; 67 // We use here the ProblemMode, but I think 68 // we can also use the Problem class. (?) 69 ProblemModel pm = new ProblemModel(); 70 if(id == null) 71 pm.Problem = new Problem(); 72 else 73 pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals((long)id)).FirstOrDefault(); 74 return View(pm); 75 } 134 // Later, we will get the runs from the session ... 135 ProblemModel pm = new ProblemModel(); 136 if (problemId != 0) 137 pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(problemId)).FirstOrDefault(); 76 138 77 /// <summary> 78 /// Controller for Index View 79 /// </summary> 80 /// <returns></returns> 81 public ActionResult Delete(long id) { 82 Session["SelectedSubMenu"] = "Problem"; 83 // We use here the ProblemMode, but I think 84 // we can also use the Problem class. (?) 85 ProblemModel pm = new ProblemModel(); 86 if(id != 0) { 87 pm.DeleteProblem(id); 88 } 89 return View("Index", pm); 90 } 91 92 public ActionResult UploadFile(FormCollection collection) { 93 Session["SelectedSubMenu"] = "Problem"; 139 pm.Problem.Name = problemName; 140 pm.Problem.Description = problemDescription; 141 pm.Problem.DataTypeName = problemDataTypeName; 142 pm.Problem.DataTypeTypeName = ""; 143 pm.Problem.ProblemClassId = problemClassId; 144 pm.Problem.PlatformId = platformId; 94 145 95 long problemId = long.Parse(collection.Get("ProblemId"));146 pm.SaveProblem(pm.Problem); 96 147 97 ProblemModel pm = new ProblemModel(); 98 99 foreach (string inputTagName in Request.Files) { 100 HttpPostedFileBase file = Request.Files[inputTagName]; 101 if (file.ContentLength > 0) { 102 // maybe for storage on server 103 //string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads"), Path.GetFileName(file.FileName)); 104 if (file.InputStream.CanRead) { 105 //file length 106 int fileLength = file.ContentLength; 107 108 //bytearray 109 byte[] data = new byte[fileLength]; 110 111 //initialize input stream 112 Stream dataStream = file.InputStream; 113 114 //read file into byte array 115 dataStream.Read(data, 0, fileLength); 116 117 //save data 118 pm.UpdateProblemData(problemId, data); 119 }//if 120 } 121 }//foreach 122 123 return View("Index", pm); 124 }//UploadFile 125 126 /// <summary> 127 /// Controller for Detail View 128 /// </summary> 129 /// <returns></returns> 130 public ActionResult SaveChanges(FormCollection collection) { 131 long problemId = long.Parse(collection.Get("ProblemId")); 132 String problemName = collection.Get("ProblemName"); 133 String problemDescription = collection.Get("ProblemDescription"); 134 String problemDataTypeName = collection.Get("ProblemDataTypeName"); 135 long problemClassId = long.Parse(collection.Get("ProblemClassId")); 136 long platformId = long.Parse(collection.Get("PlatformId")); 137 138 // Later, we will get the runs from the session ... 139 ProblemModel pm = new ProblemModel(); 140 if(problemId != 0) 141 pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(problemId)).FirstOrDefault(); 142 143 pm.Problem.Name = problemName; 144 pm.Problem.Description = problemDescription; 145 pm.Problem.DataTypeName = problemDataTypeName; 146 pm.Problem.DataTypeTypeName = ""; 147 pm.Problem.ProblemClassId = problemClassId; 148 pm.Problem.PlatformId = platformId; 149 150 pm.SaveProblem(pm.Problem); 151 152 return View("Index",pm); 153 } 154 } 148 return View("Index", pm); 149 } 150 } 155 151 }
Note: See TracChangeset
for help on using the changeset viewer.