protected override string AddBody(IDictionary<string, string> form, string sessionId = null, IDictionary<string, string> errors = null) { HtmlForm htmlForm = new HtmlForm(RequestMethod.POST, "CreateClient", errors); htmlForm.SetAttribut("novalidate", "novalidate"); if(errors != null && errors.Count > 0) { HtmlBaseTag div1 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel1 = div1.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput1 = div1.AddTag("div", null).SetAttribut("class", "forinput"); divLabel1.AddTag("lable", "Name :"); divInput1.AddTag(new HtmlInput(InputType.Text, "name", form["name"])) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid('name')"); if (errors.ContainsKey("name")) divInput1.AddTag("span", errors["name"]).SetAttribut("id", "forname"); else divInput1.AddTag("span").SetAttribut("id", "forname"); HtmlBaseTag div2 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel2 = div2.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput2 = div2.AddTag("div", null).SetAttribut("class", "forinput"); divLabel2.AddTag("lable", "Surname :"); divInput2.AddTag(new HtmlInput(InputType.Text, "surname", form["surname"])) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); if (errors.ContainsKey("surname")) divInput2.AddTag("span", errors["surname"]).SetAttribut("id", "forsurname"); else divInput2.AddTag("span").SetAttribut("id", "forsurname"); HtmlBaseTag div3 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel3 = div3.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput3 = div3.AddTag("div", null).SetAttribut("class", "forinput"); divLabel3.AddTag("lable", "Address :"); divInput3.AddTag(new HtmlInput(InputType.Text, "address", form["address"])) .SetAttribut("maxlength", "50") .SetAttribut("placeholder", "max length of 50 characters"); if (errors.ContainsKey("address")) div3.AddTag("span", errors["address"]).SetAttribut("id", "foraddress"); else div3.AddTag("span").SetAttribut("id", "foraddress"); HtmlBaseTag div4 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel4 = div4.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput4 = div4.AddTag("div", null).SetAttribut("class", "forinput"); divLabel4.AddTag("lable", "Phone :"); divInput4.AddTag(new HtmlInput(InputType.Text, "phone", form["phone"])) .SetAttribut("placeholder", "000-000-00-00") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); if (errors.ContainsKey("phone")) div4.AddTag("span", errors["phone"]).SetAttribut("id", "forphone"); else div4.AddTag("span").SetAttribut("id", "forphone"); HtmlBaseTag div5 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel5 = div5.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput5 = div5.AddTag("div", null).SetAttribut("class", "forinput"); divInput5.AddTag(new HtmlInput(InputType.Reset, "Reset", "Clin") .SetAttribut("class", "buttonsubmit")); divInput5.AddTag(new HtmlInput(InputType.Submit, "Submit", "Submit") .SetAttribut("class", "buttonsubmit")); } else { HtmlBaseTag div1 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel1 = div1.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput1 = div1.AddTag("div", null).SetAttribut("class", "forinput"); divLabel1.AddTag("lable", "Name :"); divInput1.AddTag(new HtmlInput(InputType.Text, "name", "")) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); divInput1.AddTag("span", null).SetAttribut("id", "forname"); HtmlBaseTag div2 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel2 = div2.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput2 = div2.AddTag("div", null).SetAttribut("class", "forinput"); divLabel2.AddTag("lable", "Surname :"); divInput2.AddTag(new HtmlInput(InputType.Text, "surname", "")) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); divInput2.AddTag("span").SetAttribut("id", "forsurname"); HtmlBaseTag div3 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel3 = div3.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput3 = div3.AddTag("div", null).SetAttribut("class", "forinput"); divLabel3.AddTag("lable", "Address :"); divInput3.AddTag(new HtmlInput(InputType.Text, "address", "")) .SetAttribut("maxlength", "50") .SetAttribut("placeholder", "max length of 50 characters"); divInput3.AddTag("span").SetAttribut("id", "foraddress"); HtmlBaseTag div4 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel4 = div4.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput4 = div4.AddTag("div", null).SetAttribut("class", "forinput"); divLabel4.AddTag("lable", "Phone :"); divInput4.AddTag(new HtmlInput(InputType.Text, "phone", "")) .SetAttribut("placeholder", "000-000-00-00") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); divInput4.AddTag("span").SetAttribut("id", "forphone"); HtmlBaseTag div5 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel5 = div5.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput5 = div5.AddTag("div", null).SetAttribut("class", "forinput"); divInput5.AddTag(new HtmlInput(InputType.Reset, "Reset", "Clin") .SetAttribut("class", "buttonsubmit")); divInput5.AddTag(new HtmlInput(InputType.Submit, "Submit", "Submit") .SetAttribut("class", "buttonsubmit")); } StringBuilder body = new StringBuilder(Environment.NewLine); body.Append(AddGreeting(sessionId)); body.Append(Environment.NewLine); body.Append(htmlForm.ToString(errors)); body.Append(Environment.NewLine); return body.ToString(); }
protected override string AddBody(IDictionary<string, string> form, string sessionId = null, IDictionary<string, string> errors = null) { HtmlForm htmlForm = new HtmlForm(RequestMethod.POST, "CreateManager", errors); htmlForm.SetAttribut("novalidate", "novalidate"); if (errors != null && errors.Count > 0) { htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Name: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "name", form["name"])) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "forname"); } else { htmlForm.AddTag("span").SetAttribut("id", "forname"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Surname: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "surname", form["surname"])) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "forsurname"); } else { htmlForm.AddTag("span").SetAttribut("id", "forsurname"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Address: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "address", form["address"])) .SetAttribut("maxlength", "50") .SetAttribut("placeholder", "max length of 50 characters") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "foraddress"); } else { htmlForm.AddTag("span").SetAttribut("id", "foraddress"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Phone: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "phone", form["phone"])) .SetAttribut("placeholder", "000-000-00-00") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "forphone"); } else { htmlForm.AddTag("span").SetAttribut("id", "forphone"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Login: "******"class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "login", form["login"])) .SetAttribut("maxlength", "10") .SetAttribut("placeholder", "max length of 10 characters") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "forlogin"); } else { htmlForm.AddTag("span").SetAttribut("id", "forlogin"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Password: "******"class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Password, "password", form["password"])) .SetAttribut("maxlength", "10") .SetAttribut("placeholder", "max length of 10 characters") .SetAttribut("required", "required"); if (errors.ContainsKey("name")) { htmlForm.AddTag("span", errors["name"]) .SetAttribut("id", "forpassword"); } else { htmlForm.AddTag("span").SetAttribut("id", "forpassword"); } htmlForm.AddTag("br"); htmlForm.AddTag("lable", "WorkExperience: ") .SetAttribut("class", "lable"); // ------------------------------------------------------------------------------ HtmlBaseTag selectWork = htmlForm.AddTag("select").SetAttribut("name", "experience") .SetAttribut("class", "select") .SetAttribut("size", "1"); foreach (KeyValuePair<WorkExperience, int> element in EnumService.GetAllWorkExperience()) { if (element.Key.Equals(form["experience"])) { selectWork.AddTag("option", element.Key.ToString()) .SetAttribut("selected") .SetAttribut("value", element.Value.ToString()); } else { selectWork.AddTag("option", element.Key.ToString()) .SetAttribut("value", element.Value.ToString()); } } htmlForm.AddTag("br"); htmlForm.AddTag(new HtmlInput(InputType.Reset, "Reset", "Clin")) .SetAttribut("class", "buttonclin"); htmlForm.AddTag(new HtmlInput(InputType.Submit, "Submit", "Submit")) .SetAttribut("class", "buttonsubmit"); htmlForm.AddTag("br"); } else { htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Name: ") .SetAttribut("class", "lable"); htmlForm.AddTag((new HtmlInput(InputType.Text, "name", "")) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters")) .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "forname"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Surname: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "surname", "")) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "forsurname"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Address: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "address", "")) .SetAttribut("maxlength", "50") .SetAttribut("placeholder", "max length of 50 characters") .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "foraddress"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Phone: ") .SetAttribut("class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "phone", "")) .SetAttribut("placeholder", "000-000-00-00") .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "forphone"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Login: "******"class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Text, "login", "")) .SetAttribut("maxlength", "15") .SetAttribut("placeholder", "max length of 15 characters") .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "forlogin"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "Password: "******"class", "lable"); htmlForm.AddTag(new HtmlInput(InputType.Password, "password", "")) .SetAttribut("maxlength", "10") .SetAttribut("placeholder", "max length of 10 characters") .SetAttribut("required", "required"); htmlForm.AddTag("span").SetAttribut("id", "forpassword"); htmlForm.AddTag("br"); htmlForm.AddTag("lable", "WorkExperience: ") .SetAttribut("class", "lable"); HtmlBaseTag selectWork = htmlForm.AddTag("select").SetAttribut("name", "experience") .SetAttribut("class", "select") .SetAttribut("size", "1"); foreach (KeyValuePair<WorkExperience, int> element in EnumService.GetAllWorkExperience()) { selectWork.AddTag("option", element.Key.ToString()) .SetAttribut("value", element.Value.ToString()); } htmlForm.AddTag("br"); htmlForm.AddTag(new HtmlInput(InputType.Reset, "Reset", "Clin")) .SetAttribut("class", "buttonclin"); htmlForm.AddTag(new HtmlInput(InputType.Submit, "Submit", "Submit")) .SetAttribut("class", "buttonsubmit"); htmlForm.AddTag("br"); } StringBuilder body = new StringBuilder(); body.Append(Environment.NewLine); body.Append(htmlForm.ToString(errors)); body.Append(Environment.NewLine); return body.ToString(); }
protected override string AddBody(IDictionary<string, string> form, string sessionId = null, IDictionary<string, string> errors = null) { Response response; try { IClientService cs = serviceFactory.CreateClientService(); Guid id = new Guid(form["id"]); //Client client = cs.GetElement(id); Client client = cs.GetElement(id); HtmlForm htmlForm = new HtmlForm(RequestMethod.POST, "UpdateClient", errors); htmlForm.SetAttribut("novalidate", "novalidate"); htmlForm.AddTag(new HtmlInput(InputType.Hidden, "id", client.Id.ToString())); HtmlBaseTag div1 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel1 = div1.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput1 = div1.AddTag("div", null).SetAttribut("class", "forinput"); divLabel1.AddTag("lable", "Name :"); divInput1.AddTag(new HtmlInput(InputType.Text, "name", client.Name)) .SetAttribut("maxlength", "15") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid('name')"); divInput1.AddTag("span").SetAttribut("id", "forname"); HtmlBaseTag div2 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel2 = div2.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput2 = div2.AddTag("div", null).SetAttribut("class", "forinput"); divLabel2.AddTag("lable", "Surname :"); divInput2.AddTag(new HtmlInput(InputType.Text, "surname", client.Surname)) .SetAttribut("maxlength", "15") .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); divInput2.AddTag("span").SetAttribut("id", "forsurname"); HtmlBaseTag div3 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel3 = div3.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput3 = div3.AddTag("div", null).SetAttribut("class", "forinput"); divLabel3.AddTag("lable", "Address :"); divInput3.AddTag(new HtmlInput(InputType.Text, "address", client.Address)) .SetAttribut("maxlength", "50"); div3.AddTag("span").SetAttribut("id", "foraddress"); HtmlBaseTag div4 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel4 = div4.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput4 = div4.AddTag("div", null).SetAttribut("class", "forinput"); divLabel4.AddTag("lable", "Phone :"); divInput4.AddTag(new HtmlInput(InputType.Text, "phone", client.Phone)) .SetAttribut("required", "required") .SetAttribut("onblur", "InputIsValid(this)"); div4.AddTag("span").SetAttribut("id", "forphone"); HtmlBaseTag div5 = htmlForm.AddTag("div", null).SetAttribut("class", "row"); HtmlBaseTag divLabel5 = div5.AddTag("div", null).SetAttribut("class", "forlabel"); HtmlBaseTag divInput5 = div5.AddTag("div", null).SetAttribut("class", "forinput"); divInput5.AddTag(new HtmlInput(InputType.Reset, "Reset", "Clin") .SetAttribut("class", "buttonsubmit")); divInput5.AddTag(new HtmlInput(InputType.Submit, "Submit", "Submit") .SetAttribut("class", "buttonsubmit")); StringBuilder body = new StringBuilder(Environment.NewLine); body.Append(AddGreeting(sessionId)); body.Append(Environment.NewLine); body.Append(htmlForm.ToString(errors)); body.Append(Environment.NewLine); return body.ToString(); } catch (Exception ) { response = new Response("", TypeOfAnswer.ServerError, ""); return ""; } }