Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Policy
- {
- public List<PolicyLine> PolicyLines = new List<PolicyLine>();
- }
- public class PolicyLine
- {
- public PolicyLine(bool isPositive, string policyText)
- {
- IsPositive = isPositive;
- PolicyText = policyText;
- }
- public bool IsPositive { get; set; }
- public string PolicyText { get; set; }
- }
- @Html.ActionLink("Delete", "Delete", new { id = @Model.PolicyID })
- @using (Html.BeginForm("Submit", "Policy")) {
- <fieldset>
- @Html.EditorForModel()
- </fieldset>
- }
- @model Policy
- <br />
- <label for="IsPositive">Is positive?</label>
- @Html.CheckBox("IsPositive")
- <input type="text" name="PolicyText" />
- <input type="submit" value="Add to Policy" title="SubmitFromReferalPolicy" />
- @Html.EditorFor(a => a.PolicyLines)
- @model PolicyLine
- <br />
- @this.Model.ToString()
- @Html.ActionLink("Delete", "DeleteLine/" + Model.Identifier.ToString())
- public class Policy
- {
- public string Id { get; set; }
- public List<PolicyLine> PolicyLines = new List<PolicyLine>();
- public override string ToString()
- {
- return PolicyFormatter.FormatPolicy(this);
- }
- }
- public class PolicyLine
- {
- public bool IsPositive { get; set; }
- public string PolicyText { get; set; }
- public Guid Identifier { get; set; }
- public override string ToString()
- {
- return PolicyFormatter.FormatPolicyLine(this);
- }
- }
- [HttpPost]
- public ActionResult Submit(PolicyLine submitted)
- {
- Policy saveMe = Policy.GetPolicyFromUserName(UserName);
- submitted.Identifier = Guid.NewGuid();
- saveMe.PolicyLines.Add(submitted);
- Store.Write(saveMe);
- return RedirectToAction("Index");
- }
- public ActionResult DeleteLine(Guid identifier)
- {
- Policy saveMe = Policy.GetPolicyFromUserName(UserName);
- PolicyLine removeMe = saveMe.PolicyLines.Find(p => p.Identifier == identifier);
- saveMe.PolicyLines.Remove(removeMe);
- Store.Write(saveMe);
- return RedirectToAction("Index");
- }
Add Comment
Please, Sign In to add comment