public ActionResult Index(String operand, String operand2)
        {
            return authenticatedAction(new String[] { "UR" }, () => {
                ObjectSet<IssueSourceLvl3> table = (new ModelsDataContext()).IssueSourceLvl3s;
                IssueSourceLvl2 parent = (new ModelsDataContext()).IssueSourceLvl2s.Where(s => s.code == operand2).First();
                IssueSourceLvl1 grandParent = (new ModelsDataContext()).IssueSourceLvl1s.Where(s => s.code == operand).First();
                return formAction(
                    () => {
                        logger.Debug(className + ".Index accessed.");
                        ViewData["Parent"] = parent;
                        ViewData["GrandParent"] = grandParent;
                        ViewData["Items"] = table.Where(s => s.grandparentCode == operand).Where(s => s.parentCode == operand2).OrderBy(i => i.sortIndex).ToList();
                        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"];
                            IssueSourceLvl3 possibleItem = table.Where(s => s.grandparentCode == operand).Where(s => s.parentCode == operand2).FirstOrDefault(p => p.code == code);

                            //VALIDATION HAPPENS HERE
                            validationLogPrefix = className + ".Index";
                            ValidateStrLen(itemPair.Value["description"], 32, "Level three 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 IssueSourceLvl3();
                                possibleItem.grandparentCode = operand;
                                possibleItem.parentCode = operand2;
                                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_CRFSRP3");
                    }));
            });
        }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the IssueSourceLvl3s EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToIssueSourceLvl3s(IssueSourceLvl3 issueSourceLvl3)
 {
     base.AddObject("IssueSourceLvl3s", issueSourceLvl3);
 }
示例#3
0
 /// <summary>
 /// Create a new IssueSourceLvl3 object.
 /// </summary>
 /// <param name="grandparentCode">Initial value of the grandparentCode property.</param>
 /// <param name="parentCode">Initial value of the parentCode property.</param>
 /// <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 IssueSourceLvl3 CreateIssueSourceLvl3(global::System.String grandparentCode, global::System.String parentCode, global::System.String code, global::System.String description, global::System.Int16 sortIndex, global::System.String active_p)
 {
     IssueSourceLvl3 issueSourceLvl3 = new IssueSourceLvl3();
     issueSourceLvl3.grandparentCode = grandparentCode;
     issueSourceLvl3.parentCode = parentCode;
     issueSourceLvl3.code = code;
     issueSourceLvl3.description = description;
     issueSourceLvl3.sortIndex = sortIndex;
     issueSourceLvl3.active_p = active_p;
     return issueSourceLvl3;
 }