public ActionResult Index()
        {
            return authenticatedAction(new String[] { "UR" }, () => formAction(
                    () => {
                        logger.Debug(className + ".Index accessed.");
                        ViewData["Items"] = table.OrderBy(p => p.sortIndex).ToList();
                        var hlp = new UrlHelper(this.ControllerContext.RequestContext);
                        var foo = hlp.RouteUrl("ReferenceData", new { controller = "IssueSourceLvl2s", operand = "foo" });
                        return View();
                    },
                    () => sideEffectingAction(() => {
                        logger.Debug(className + ".Index updating.");

                        //update properties of each row, with the exception of...
                        var formVars = extractRowParams(Request.Form);
                        foreach (KeyValuePair<String, Dictionary<String, String>> itemPair in formVars) {
                            var code = itemPair.Value["code"];
                            IssueSourceLvl1 possibleItem = table.FirstOrDefault(p => p.code == code);

                            //VALIDATION HAPPENS HERE
                            validationLogPrefix = className + ".Index";
                            ValidateStrLen(itemPair.Value["description"], 32, "Level one issue source descriptions");
                            //AND THEN ENDS.

                            //does it exist - or do we have to add it in?
                            if (possibleItem != null) {
                                possibleItem.description = itemPair.Value["description"];
                                logger.DebugFormat(className + ".Index updating {0}", possibleItem.ToString());
                            } else {
                                possibleItem = new IssueSourceLvl1();
                                possibleItem.code = itemPair.Value["code"];
                                possibleItem.description = itemPair.Value["description"];
                                possibleItem.active_p = "A";
                                table.AddObject(possibleItem);
                                logger.ErrorFormat(className + ".Index adding {0} with description {1}", itemPair.Key, itemPair.Value["description"]);
                            }

                            //set the "active" as well.
                            if (itemPair.Value.ContainsKey("active")) {
                                possibleItem.active_p = "A";
                            } else {
                                possibleItem.active_p = "N";
                            }

                            table.Context.SaveChanges();
                        }

                        //orderingindex, which we do seperately.
                        setSortIndexes(table, x => x.code);

                        updateTableTimestamp("T_CRFSRP1");
                    }
               )));
        }
Esempio n. 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the IssueSourceLvl1s EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIssueSourceLvl1s(IssueSourceLvl1 issueSourceLvl1)
 {
     base.AddObject("IssueSourceLvl1s", issueSourceLvl1);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new IssueSourceLvl1 object.
 /// </summary>
 /// <param name="code">Initial value of the code property.</param>
 /// <param name="description">Initial value of the description property.</param>
 /// <param name="sortIndex">Initial value of the sortIndex property.</param>
 /// <param name="active_p">Initial value of the active_p property.</param>
 public static IssueSourceLvl1 CreateIssueSourceLvl1(global::System.String code, global::System.String description, global::System.Int16 sortIndex, global::System.String active_p)
 {
     IssueSourceLvl1 issueSourceLvl1 = new IssueSourceLvl1();
     issueSourceLvl1.code = code;
     issueSourceLvl1.description = description;
     issueSourceLvl1.sortIndex = sortIndex;
     issueSourceLvl1.active_p = active_p;
     return issueSourceLvl1;
 }