// /Admin/UpdatePurchaseType private static int? CreateDealClosingCostType(CookieCollection cookies, string dealClosingCostType, out string resp) { resp = string.Empty; int? dealClosingCostTypeID = null; DeepBlue.Models.Admin.EditDealClosingCostTypeModel model = new DeepBlue.Models.Admin.EditDealClosingCostTypeModel(); model.Name = dealClosingCostType; NameValueCollection formValues = HttpWebRequestUtil.SetUpForm(model, string.Empty, string.Empty); string url = HttpWebRequestUtil.GetUrl("Admin/UpdateDealClosingCostType"); byte[] postData = System.Text.Encoding.ASCII.GetBytes(HttpWebRequestUtil.ToFormValue(formValues)); HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, postData, true, cookies); if (response.StatusCode == System.Net.HttpStatusCode.OK) { using (Stream receiveStream = response.GetResponseStream()) { // Pipes the stream to a higher level stream reader with the required encoding format. using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) { resp = readStream.ReadToEnd(); if (!string.IsNullOrEmpty(resp)) { dealClosingCostTypeID = HttpWebRequestUtil.GetNewKeyFromResponse(resp); } response.Close(); readStream.Close(); } } } return dealClosingCostTypeID; }
public ActionResult UpdateDealClosingCostType(FormCollection collection) { EditDealClosingCostTypeModel model=new EditDealClosingCostTypeModel(); ResultModel resultModel=new ResultModel(); this.TryUpdateModel(model); string ErrorMessage=DealClosingCostTypeNameAvailable(model.Name,model.DealClosingCostTypeId); if(String.IsNullOrEmpty(ErrorMessage)==false) { ModelState.AddModelError("Name",ErrorMessage); } if(ModelState.IsValid) { DealClosingCostType dealClosingCostType=AdminRepository.FindDealClosingCostType(model.DealClosingCostTypeId); if(dealClosingCostType==null) { dealClosingCostType=new DealClosingCostType(); } dealClosingCostType.Name=model.Name; dealClosingCostType.EntityID=Authentication.CurrentEntity.EntityID; IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveDealClosingCostType(dealClosingCostType); if(errorInfo!=null) { resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo); } else { resultModel.Result="True||"+dealClosingCostType.DealClosingCostTypeID; } } else { foreach(var values in ModelState.Values.ToList()) { foreach(var err in values.Errors.ToList()) { if(string.IsNullOrEmpty(err.ErrorMessage)==false) { resultModel.Result+=err.ErrorMessage+"\n"; } } } } return View("Result",resultModel); }