Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/11 13:39:31 (13 years ago)
Author:
gschwarz
Message:

#1433 Updated Problem Control/View

Location:
branches/WebApplication/MVC2/HLWebOKBAdminPlugin
Files:
5 edited

Legend:

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

    r6117 r6142  
    4242
    4343            return View(algorithmClasses);
    44         }//ActionResult AlgorithmClass
     44        }//ActionResult AlgorithmClassC:\SYS\profiles\schwgh\Desktop\WebApplication\MVC2\HLWebOKBAdminPlugin\Views\Admin\Algorithm.aspx
    4545
    4646        public ActionResult Algorithm() {
     
    7373            return View(problem);
    7474        }//Problem
     75
     76        public ActionResult OKBNamedItemList_Test() {
     77            return View();
     78        }//Problem
     79
    7580    }
    7681}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Controllers/ProblemController.cs

    r6130 r6142  
    3636            // we can also use the Problem class. (?)
    3737      ProblemModel pm = new ProblemModel();
    38             pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(id)).FirstOrDefault();
     38            if(id == 0)
     39                pm.Problem = new Problem();
     40            else
     41                pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(id)).FirstOrDefault();
    3942      return View(pm);
    4043    }
    4144
     45        public ActionResult SaveChanges(FormCollection collection) {           
     46            long problemId = long.Parse(collection.Get("ProblemId"));
     47            String problemName = collection.Get("ProblemName");
     48            String problemDescription = collection.Get("ProblemDescription");
     49            String problemDataTypeName = collection.Get("ProblemDataTypeName");
     50            long problemClassId = long.Parse(collection.Get("ProblemClassId"));
     51            long plattformId = long.Parse(collection.Get("PlattformId"));
     52
     53            // Later, we will get the runs from the session ...
     54            ProblemModel pm = new ProblemModel();
     55            pm.Problem = (Problem)pm.Problems.Where(x => x.Id.Equals(problemId)).FirstOrDefault();
     56
     57            pm.Problem.Name = problemName;
     58            pm.Problem.Description = problemDescription;
     59            pm.Problem.DataTypeName = problemDataTypeName;
     60            pm.Problem.ProblemClassId = problemClassId;
     61            pm.Problem.PlatformId = plattformId;
     62
     63            pm.SaveProblem(pm.Problem);
     64
     65            return View("Index",pm);
     66        }
     67
     68        //public ActionResult CreateProblem(FormCollection collection) {
     69        //    Problem problem = new Problem();
     70        //    String problemName = collection.Get("ProblemName");
     71        //    long problemClassId = long.Parse(collection.Get("ProblemClassId"));
     72        //    long plattformId = long.Parse(collection.Get("PlattformId"));
     73        //    problem.Name = problemName;
     74        //    problem.ProblemClassId = problemClassId;
     75        //    problem.PlatformId = plattformId;
     76        //    problem.DataTypeName = "";
     77        //    problem.DataTypeTypeName = "";
     78        //    problem.Description = "";
     79
     80        //    // Later, we will get the runs from the session ..
     81        //    ProblemModel pm = new ProblemModel();
     82        //    pm.CreateProblem(problem);
     83
     84        //    return View("Index", pm);
     85        //}
     86
    4287  }
    4388}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Models/ProblemModel.cs

    r6130 r6142  
    2121                Problem[] problems = adminClient.GetProblems();
    2222                return problems.ToList<Problem>();
     23            }
     24        }
    2325
     26        public List<ProblemClass> ProblemClasses {
     27            get {
     28                AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
     29                IList<ProblemClass> problemClassList = new List<ProblemClass>();
     30                ProblemClass[] problemClass = adminClient.GetProblemClasses();
     31                return problemClass.ToList<ProblemClass>();
     32            }
     33        }
     34
     35        public List<Platform> Plattforms {
     36            get {
     37                AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
     38                IList<Platform> plattformList = new List<Platform>();
     39                Platform[] plattforms = adminClient.GetPlatforms();
     40                return plattforms.ToList<Platform>();
    2441            }
    2542        }
     
    3047        public Problem Problem { get; set; }
    3148
     49        public void SaveProblem(Problem problem) {
     50            AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
     51            adminClient.UpdateProblem(problem);
     52        }
     53
     54        public void CreateProblem(Problem problem) {
     55            AdministrationServiceClient adminClient = Admin.GetClientFactory("okbtester", "okbtester");
     56            adminClient.AddProblem(problem);
     57        }
     58
    3259    }
    3360}
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Problem/Detail.aspx

    r6130 r6142  
    77</asp:Content>
    88<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     9    <% using(Html.BeginForm("SaveChanges", "Problem")) %>
     10    <% { %>
    911    <h2>
    1012        Detail</h2>
     
    1820        Problem p = ((ProblemModel)Model).Problem;
    1921    %>
    20     Id:
    21     <%: Html.Label(p.Id.ToString()) %><br />
    22     Name:
    23     <%: Html.Label(p.Name) %><br />
    24     Description:
    25     <%: Html.Label(p.Description) %><br />
    26     DataTypeName:
    27     <%: Html.Label(p.DataTypeName) %><br />
     22    <table border="1">
     23        <tr>
     24            <td>
     25                Id:
     26            </td>
     27            <td>
     28                <%: Html.Label(p.Id.ToString())%>
     29            </td>
     30            <%: Html.Hidden("ProblemId", p.Id.ToString(), p.Id.ToString())%>
     31        </tr>
     32        <tr>
     33            <td>
     34                Name:
     35            </td>
     36            <td>
     37                <%: Html.TextBox("ProblemName", p.Name, p.Name)%>
     38            </td>
     39        </tr>
     40        <tr>
     41            <td>
     42                Description:
     43            </td>
     44            <td>
     45                <%: Html.TextBox("ProblemDescription", p.Description, p.Description)%>
     46            </td>
     47        </tr>
     48        <tr>
     49            <td>
     50                DataTypeName:
     51            </td>
     52            <td>
     53                <%: Html.TextBox("ProblemDataTypeName", p.DataTypeName, p.DataTypeName)%>
     54            </td>
     55        </tr>
     56        <tr>
     57            <td>
     58                Problem Class:
     59            </td>
     60            <td>
     61                <select name="ProblemClassId">
     62                    <% foreach(ProblemClass pc in ((ProblemModel)Model).ProblemClasses) {  %>
     63                            <option value="<%=pc.Id%>"><%=pc.Name%></option>
     64                    <% } %>
     65                </select>
     66            </td>
     67        </tr>
     68        <tr>
     69            <td>
     70                Plattforms:
     71            </td>
     72            <td>
     73                <select name="PlattformId">
     74                    <% foreach(Platform pc in ((ProblemModel)Model).Plattforms) {  %>
     75                            <option value="<%=pc.Id%>"><%=pc.Name%></option>
     76                    <% } %>
     77                </select>
     78            </td>
     79        </tr>
     80        <tr>
     81            <td>
     82                Action:
     83            </td>
     84            <td>
     85                <input type="submit" value="save" />
     86            </td>
     87        </tr>
     88    </table>   
     89    <%: Html.ActionLink("back to Index","Index") %>
     90    <% } %>
    2891</asp:Content>
  • branches/WebApplication/MVC2/HLWebOKBAdminPlugin/Views/Problem/Index.aspx

    r6130 r6142  
    77</asp:Content>
    88<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    9     <h2>
    10         Problems</h2>
    11     <table>
    12         <tr>
    13             <td>
    14                 <ul>
    15                     <%
    16                         // We get this from the Controller (Index)
    17                         foreach (Problem p in ((ProblemModel)Model).Problems)
    18                         {  %>
    19                     <li>
    20                         <%: Html.ActionLink(p.Name, "Detail",new {p.Id}) %></li>
    21                     <% } %>
    22                 </ul>
    23             </td>
    24             <td>
    25                 <!-- maybe we can use here partial views that will be shown ...-->
    26             </td>
    27         </tr>
    28     </table>
     9    <h2>Problems</h2>
     10    <div style="height:150px; overflow:scroll;">
     11        <table>
     12            <!--// We get this from the Controller (Index)-->
     13            <% foreach(Problem p in ((ProblemModel)Model).Problems) {  %>
     14            <tr>
     15                <td>
     16                    <%: Html.ActionLink(p.Name, "Detail",new {p.Id}) %>
     17                </td>
     18                <td>
     19                    <%: Html.Label(p.Description) %>
     20                </td>
     21                <td>
     22                    <%: Html.Label(p.DataTypeName)%>
     23                </td>
     24            </tr>
     25            <% } %>
     26        </table>
     27    </div>
     28
     29     
     30    <h2>Create new Problem</h2>
     31 
     32       
    2933</asp:Content>
Note: See TracChangeset for help on using the changeset viewer.