Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/27/11 19:09:49 (14 years ago)
Author:
jwolfing
Message:

#1433 code formatted

Location:
branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AdminController.cs

    r6290 r6317  
    1313
    1414namespace HLWebOKBAdminPlugin.Controllers {
    15     public class AdminController : Controller {
    16         private AdministrationServiceClient CertificateValidator() {
    17             AdministrationServiceClient asc = new AdministrationServiceClient();
     15  public class AdminController : Controller {
     16    private AdministrationServiceClient CertificateValidator() {
     17      AdministrationServiceClient asc = new AdministrationServiceClient();
    1818
    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;
     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;
    2222
    23             return asc;
    24         }//CertificateValidator
     23      return asc;
     24    }//CertificateValidator
    2525
    26         public ActionResult Index() {
    27             return View();
    28         }// ActionResult Index
     26    public ActionResult Index() {
     27      return View();
     28    }// ActionResult Index
    2929
    30         public ActionResult Menu() {
    31            
    32             return View();
    33         }//ActionResult Men
     30    public ActionResult Menu() {
    3431
    35         public ActionResult AlgorithmClass() {
    36             AdministrationServiceClient adminCLient = Admin.GetClientFactory();
     32      return View();
     33    }//ActionResult Men
    3734
    38             AdminModel am = new AdminModel();
    39             Session["SelectedSubMenu"] = "AlgorithmClass";
    40             var algorithmClasses = am.AlgorithmClassProp;
     35    public ActionResult AlgorithmClass() {
     36      AdministrationServiceClient adminCLient = Admin.GetClientFactory();
    4137
    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;
    4441
    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
    4744
    48             AdminModel am = new AdminModel();
    49             Session["SelectedSubMenu"] = "Algorithm";
    50             var algorithm = am.AlgorithmsGetAll();
     45    public ActionResult Algorithm() {
     46      AdministrationServiceClient adminCLient = Admin.GetClientFactory();
    5147
    52             return View(algorithm);
    53         }//Algorithm
     48      AdminModel am = new AdminModel();
     49      Session["SelectedSubMenu"] = "Algorithm";
     50      var algorithm = am.AlgorithmsGetAll();
    5451
    55         public ActionResult ProblemClass() {
    56             AdministrationServiceClient adminCLient = Admin.GetClientFactory();
     52      return View(algorithm);
     53    }//Algorithm
    5754
    58             AdminModel am = new AdminModel();
    59             Session["SelectedSubMenu"] = "ProblemClass";
    60             var problemClasses = am.ProblemClassGetAll();
     55    public ActionResult ProblemClass() {
     56      AdministrationServiceClient adminCLient = Admin.GetClientFactory();
    6157
    62             return View(problemClasses);
    63         }//ProblemClass
     58      AdminModel am = new AdminModel();
     59      Session["SelectedSubMenu"] = "ProblemClass";
     60      var problemClasses = am.ProblemClassGetAll();
    6461
    65         public ActionResult Problem() {
    66             AdministrationServiceClient adminCLient = Admin.GetClientFactory();
     62      return View(problemClasses);
     63    }//ProblemClass
    6764
    68             AdminModel am = new AdminModel();
    69             Session["SelectedSubMenu"] = "Problem";
    70             var problem = am.ProblemsGetAll();
     65    public ActionResult Problem() {
     66      AdministrationServiceClient adminCLient = Admin.GetClientFactory();
    7167
    72             return View(problem);
    73         }//Problem
     68      AdminModel am = new AdminModel();
     69      Session["SelectedSubMenu"] = "Problem";
     70      var problem = am.ProblemsGetAll();
    7471
    75         public ActionResult OKBNamedItemList_Test() {
    76             return View();
    77         }//Problem
     72      return View(problem);
     73    }//Problem
    7874
    79     }
     75    public ActionResult OKBNamedItemList_Test() {
     76      return View();
     77    }//Problem
     78
     79  }
    8080}
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmClassController.cs

    r6290 r6317  
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
    88
    9 namespace HLWebOKBAdminPlugin.Controllers
    10 {
    11     public class AlgorithmClassController : Controller
    12     {
    13         //
    14         // GET: /AlgorithmClass/
     9namespace HLWebOKBAdminPlugin.Controllers {
     10  public class AlgorithmClassController : Controller {
     11    //
     12    // GET: /AlgorithmClass/
    1513
    16         public ActionResult Index() {
     14    public ActionResult Index() {
    1715
    18             Session["SelectedSubMenu"] = "AlgorithmClass";
    19             AlgorithmClassModel acm = new AlgorithmClassModel();
    20             return View(acm);
    21         }//Index
     16      Session["SelectedSubMenu"] = "AlgorithmClass";
     17      AlgorithmClassModel acm = new AlgorithmClassModel();
     18      return View(acm);
     19    }//Index
    2220
    23         public ActionResult Detail(long? id) {
    24             Session["SelectedSubMenu"] = "AlgorithmClass";
    25             AlgorithmClassModel acm = new AlgorithmClassModel();
     21    public ActionResult Detail(long? id) {
     22      Session["SelectedSubMenu"] = "AlgorithmClass";
     23      AlgorithmClassModel acm = new AlgorithmClassModel();
    2624
    27             if (id == null)
    28                 acm.AlgorithmClass = new AlgorithmClass();
    29             else
    30                 acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals((long)id)).FirstOrDefault();
    31             return View(acm);
    32         }//Detail
     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
    3331
    34         /// <summary>
    35         /// Controller for Index View
    36         /// </summary>
    37         /// <returns></returns>
    38         public ActionResult Delete(long? id) {
    39             Session["SelectedSubMenu"] = "AlgorithmClass";
     32    /// <summary>
     33    /// Controller for Index View
     34    /// </summary>
     35    /// <returns></returns>
     36    public ActionResult Delete(long? id) {
     37      Session["SelectedSubMenu"] = "AlgorithmClass";
    4038
    41             AlgorithmClassModel acm = new AlgorithmClassModel();
    42             if (id != 0) {
    43                 acm.DeleteAlgorithmClass((long)id);
    44             }
    45             return View("Index", acm);
    46         }//Delete
     39      AlgorithmClassModel acm = new AlgorithmClassModel();
     40      if (id != 0) {
     41        acm.DeleteAlgorithmClass((long)id);
     42      }
     43      return View("Index", acm);
     44    }//Delete
    4745
    48         /// <summary>
    49         /// Controller for Detail View
    50         /// </summary>
    51         /// <returns></returns>
    52         public ActionResult SaveChanges(FormCollection collection) {
    53             long algorithmClassId = long.Parse(collection.Get("AlgorithmClassId"));
    54             String algorithmClassName = collection.Get("AlgorithmClassName");
    55             String algorithmClassDescription = collection.Get("AlgorithmClassDescription");
     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");
    5654
    57             // Later, we will get the runs from the session ...
    58             AlgorithmClassModel acm = new AlgorithmClassModel();
    59             if (algorithmClassId != 0)
    60                 acm.AlgorithmClass = (AlgorithmClass)acm.AlgorithmClasses.Where(x => x.Id.Equals(algorithmClassId)).FirstOrDefault();
     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();
    6159
    62             acm.AlgorithmClass.Name = algorithmClassName;
    63             acm.AlgorithmClass.Description = algorithmClassDescription;
     60      acm.AlgorithmClass.Name = algorithmClassName;
     61      acm.AlgorithmClass.Description = algorithmClassDescription;
    6462
    65             acm.SaveAlgorithmClass(acm.AlgorithmClass);
     63      acm.SaveAlgorithmClass(acm.AlgorithmClass);
    6664
    67             return View("Index", acm);
    68         }//SaveChanges
     65      return View("Index", acm);
     66    }//SaveChanges
    6967
    70         /// <summary>
    71         /// Controller for Index View
    72         /// </summary>
    73         /// <returns></returns>
    74         public ActionResult SortAsc() {
    75             Session["SelectedSubMenu"] = "AlgorithmClass";
    76             AlgorithmClassModel acm = new AlgorithmClassModel();
    77             acm.AlgorithmClasses = acm.AlgorithmClasses.OrderBy(x => x.Name).ToList<AlgorithmClass>();
    78             return View("Index", acm);
    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    }
    8078
    81         /// <summary>
    82         /// Controller for Index View
    83         /// </summary>
    84         /// <returns></returns>
    85         public ActionResult SortDesc() {
    86             Session["SelectedSubMenu"] = "AlgorithmClass";
    87             AlgorithmClassModel acm = new AlgorithmClassModel();
     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();
    8886
    89             IOrderedEnumerable<AlgorithmClass> acmOrderedList = acm.AlgorithmClasses.OrderByDescending(x => x.Name);
    90             IList<AlgorithmClass> acmList = new List<AlgorithmClass>();
    91             foreach (var item in acmOrderedList) {
    92                 acmList.Add(item);
    93             }
    94             acm.AlgorithmClasses = acmList;
     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;
    9593
    96             // this should be the right code
    97             //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
    98             return View("Index", acm);
    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    }
    10098
    101     }
     99  }
    102100}
    103101
    104    
     102
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/AlgorithmController.cs

    r6283 r6317  
    88using System.IO;
    99
    10 namespace HLWebOKBAdminPlugin.Controllers
    11 {
     10namespace HLWebOKBAdminPlugin.Controllers {
     11  /// <summary>
     12  /// Controller for Algorithm Submenu
     13  /// </summary>
     14  public class AlgorithmController : Controller {
    1215    /// <summary>
    13     /// Controller for Algorithm Submenu
     16    /// Controller for Index View
    1417    /// </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    }
    2724
    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
    37106        }
     107      }//foreach
    38108
    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
    66111
    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"));
    81123
    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();
    84128
    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;
    86135
    87             AlgorithmModel pm = new AlgorithmModel();
     136      pm.SaveAlgorithm(pm.Algorithm);
    88137
    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  }
    145141}
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/HomeController.cs

    r6283 r6317  
    55using System.Web.Mvc;
    66
    7 namespace HLWebOKBAdminPlugin.Controllers
    8 {
    9     [HandleError]
    10     public class HomeController : Controller
    11     {
    12         //
    13         // GET: /Home/
     7namespace HLWebOKBAdminPlugin.Controllers {
     8  [HandleError]
     9  public class HomeController : Controller {
     10    //
     11    // GET: /Home/
    1412
    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    }
    2017
    21         public ActionResult About() {
    22             return View();
    23         }
     18    public ActionResult About() {
     19      return View();
     20    }
    2421
    25     }
     22  }
    2623}
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/PlatformController.cs

    r6313 r6317  
    77using HLWebOKBAdminPlugin.OKBAdministrationService;
    88
    9 namespace HLWebOKBAdminPlugin.Controllers
    10 {
    11     public class PlatformController : Controller
    12     {
    13         //
    14         // GET: /Platform/
     9namespace HLWebOKBAdminPlugin.Controllers {
     10  public class PlatformController : Controller {
     11    //
     12    // GET: /Platform/
    1513
    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
    2219
    2320
    24         public ActionResult Detail(long? id) {
    25             Session["SelectedSubMenu"] = "Platform";
    26             PlatformModel plm = new PlatformModel();
     21    public ActionResult Detail(long? id) {
     22      Session["SelectedSubMenu"] = "Platform";
     23      PlatformModel plm = new PlatformModel();
    2724
    28             if (id == null)
    29                 plm.Platform = new Platform();
    30             else
    31                 plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals((long)id)).FirstOrDefault();
    32             return View(plm);
    33         }//Detail
     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
    3431
    35         public ActionResult Delete(long? id) {
    36             Session["SelectedSubMenu"] = "Platform";
     32    public ActionResult Delete(long? id) {
     33      Session["SelectedSubMenu"] = "Platform";
    3734
    38             PlatformModel plm = new PlatformModel();
    39             if (id != 0) {
    40                 plm.DeletePlatform((long)id);
    41             }
    42             return View("Index", plm);
    43         }//Delete
     35      PlatformModel plm = new PlatformModel();
     36      if (id != 0) {
     37        plm.DeletePlatform((long)id);
     38      }
     39      return View("Index", plm);
     40    }//Delete
    4441
    45         public ActionResult SaveChanges(FormCollection collection) {
    46             long platformId = long.Parse(collection.Get("PlatformId"));
    47             String platformName = collection.Get("PlatformName");
    48             String platformDescription = collection.Get("PlatformDescription");
     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");
    4946
    50             // Later, we will get the runs from the session ...
    51             PlatformModel plm = new PlatformModel();
    52             if (platformId != 0)
    53                 plm.Platform = (Platform)plm.Platforms.Where(x => x.Id.Equals(platformId)).FirstOrDefault();
     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();
    5451
    55             plm.Platform.Name = platformName;
    56             plm.Platform.Description = platformDescription;
     52      plm.Platform.Name = platformName;
     53      plm.Platform.Description = platformDescription;
    5754
    58             plm.SavePlatform(plm.Platform);
     55      plm.SavePlatform(plm.Platform);
    5956
    60             return View("Index", plm);
    61         }//SaveChanges
     57      return View("Index", plm);
     58    }//SaveChanges
    6259
    63         public ActionResult SortAsc() {
    64             Session["SelectedSubMenu"] = "Platform";
    65             PlatformModel plm = new PlatformModel();
    66             plm.Platforms = plm.Platforms.OrderBy(x => x.Name).ToList<Platform>();
    67             return View("Index", plm);
    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    }
    6966
    70         /// <summary>
    71         /// Controller for Index View
    72         /// </summary>
    73         /// <returns></returns>
    74         public ActionResult SortDesc() {
    75             Session["SelectedSubMenu"] = "Platform";
    76             PlatformModel plm = new PlatformModel();
     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();
    7774
    78             IOrderedEnumerable<Platform> plmOrderedList = plm.Platforms.OrderByDescending(x => x.Name);
    79             IList<Platform> plmList = new List<Platform>();
    80             foreach (var item in plmOrderedList) {
    81                 plmList.Add(item);
    82             }
    83             plm.Platforms = plmList;
     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;
    8481
    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);
    8985    }
     86  }
    9087}
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemClassController.cs

    r6283 r6317  
    88
    99
    10 namespace HLWebOKBAdminPlugin.Controllers
    11 {
    12     // <summary>
    13     // Controller for ProblemClass Submenu
    14     // </summary>
    15     public class ProblemClassController : Controller
    16     {
    17         //
    18         // GET: /ProblemClass/
     10namespace HLWebOKBAdminPlugin.Controllers {
     11  // <summary>
     12  // Controller for ProblemClass Submenu
     13  // </summary>
     14  public class ProblemClassController : Controller {
     15    //
     16    // GET: /ProblemClass/
    1917
    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
    2623
    27         public ActionResult Detail(long? id) {
    28             Session["SelectedSubMenu"] = "ProblemClass";
    29             ProblemClassModel pcm = new ProblemClassModel();
     24    public ActionResult Detail(long? id) {
     25      Session["SelectedSubMenu"] = "ProblemClass";
     26      ProblemClassModel pcm = new ProblemClassModel();
    3027
    31             if (id == null)
    32                 pcm.ProblemClass = new ProblemClass();
    33             else
    34                 pcm.ProblemClass = (ProblemClass)pcm.ProblemClasses.Where(x => x.Id.Equals((long)id)).FirstOrDefault();
    35             return View(pcm);
    36         }//Detail
     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
    3734
    38         /// <summary>
    39         /// Controller for Index View
    40         /// </summary>
    41         /// <returns></returns>
    42         public ActionResult Delete(long? id) {
    43             Session["SelectedSubMenu"] = "ProblemClass";
     35    /// <summary>
     36    /// Controller for Index View
     37    /// </summary>
     38    /// <returns></returns>
     39    public ActionResult Delete(long? id) {
     40      Session["SelectedSubMenu"] = "ProblemClass";
    4441
    45             ProblemClassModel pcm = new ProblemClassModel();
    46             if (id != 0) {
    47                 pcm.DeleteProblemClass((long)id);
    48             }
    49             return View("Index", pcm);
    50         }//Delete
     42      ProblemClassModel pcm = new ProblemClassModel();
     43      if (id != 0) {
     44        pcm.DeleteProblemClass((long)id);
     45      }
     46      return View("Index", pcm);
     47    }//Delete
    5148
    52         /// <summary>
    53         /// Controller for Detail View
    54         /// </summary>
    55         /// <returns></returns>
    56         public ActionResult SaveChanges(FormCollection collection) {
    57             long problemClassId = long.Parse(collection.Get("ProblemClassId"));
    58             String problemClassName = collection.Get("ProblemClassName");
    59             String problemClassDescription = collection.Get("ProblemClassDescription");
     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");
    6057
    61             // Later, we will get the runs from the session ...
    62             ProblemClassModel pcm = new ProblemClassModel();
    63             if (problemClassId != 0)
    64                 pcm.ProblemClass = (ProblemClass)pcm.ProblemClasses.Where(x => x.Id.Equals(problemClassId)).FirstOrDefault();
     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();
    6562
    66             pcm.ProblemClass.Name = problemClassName;
    67             pcm.ProblemClass.Description = problemClassDescription;
     63      pcm.ProblemClass.Name = problemClassName;
     64      pcm.ProblemClass.Description = problemClassDescription;
    6865
    69             pcm.SaveProblemClass(pcm.ProblemClass);
     66      pcm.SaveProblemClass(pcm.ProblemClass);
    7067
    71             return View("Index", pcm);
    72         }//SaveChanges
     68      return View("Index", pcm);
     69    }//SaveChanges
    7370
    74         /// <summary>
    75         /// Controller for Index View
    76         /// </summary>
    77         /// <returns></returns>
    78         public ActionResult SortAsc() {
    79             Session["SelectedSubMenu"] = "ProblemClass";
    80             ProblemClassModel pcm = new ProblemClassModel();
    81             pcm.ProblemClasses = pcm.ProblemClasses.OrderBy(x => x.Name).ToList<ProblemClass>();
    82             return View("Index", pcm);
    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    }
    8481
    85         /// <summary>
    86         /// Controller for Index View
    87         /// </summary>
    88         /// <returns></returns>
    89         public ActionResult SortDesc() {
    90             Session["SelectedSubMenu"] = "ProblemClass";
    91             ProblemClassModel pcm = new ProblemClassModel();
     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();
    9289
    93             IOrderedEnumerable<ProblemClass> pcmOrderedList = pcm.ProblemClasses.OrderByDescending(x => x.Name);
    94             IList<ProblemClass> pcmList = new List<ProblemClass>();
    95             foreach (var item in pcmOrderedList) {
    96                 pcmList.Add(item);
    97             }
    98             pcm.ProblemClasses = pcmList;
     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;
    9996
    100             // this should be the right code
    101             //pm.Problems = pm.Problems.OrderByDescending(x => x.Name).ToArray<Problem>();
    102             return View("Index", pcm);
    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    }
    104101
    105     }
     102  }
    106103}
  • TabularUnified branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs

    r6283 r6317  
    88using System.IO;
    99
    10 namespace HLWebOKBAdminPlugin.Controllers
    11 {
     10namespace HLWebOKBAdminPlugin.Controllers {
     11  /// <summary>
     12  /// Controller for Problem Submenu
     13  /// </summary>
     14  public class ProblemController : Controller {
    1215    /// <summary>
    13     /// Controller for Problem Submenu
     16    /// Controller for Index View
    1417    /// </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    }
    2724
    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
    37116        }
     117      }//foreach
    38118
    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
    46121
    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"));
    54133
    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();
    76138
    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;
    94145
    95             long problemId = long.Parse(collection.Get("ProblemId"));           
     146      pm.SaveProblem(pm.Problem);
    96147
    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  }
    155151}
Note: See TracChangeset for help on using the changeset viewer.