예제 #1
1
 public static List<DeepBlue.Models.Entity.DealClosingCostType> GetDealClosingCostTypesFromDeepBlue(CookieCollection cookies)
 {
     // Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc
     List<DeepBlue.Models.Entity.DealClosingCostType> dealClosingCostTypes = new List<DeepBlue.Models.Entity.DealClosingCostType>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/DealClosingCostTypeList?pageIndex=1&pageSize=5000&sortName=Name&sortOrder=asc");
     HttpWebResponse response = HttpWebRequestUtil.SendRequest(url, null, false, cookies, false, HttpWebRequestUtil.JsonContentType);
     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)) {
                 string resp = readStream.ReadToEnd();
                 if (!string.IsNullOrEmpty(resp)) {
                     JavaScriptSerializer js = new JavaScriptSerializer();
                     FlexigridData flexiGrid = (FlexigridData)js.Deserialize(resp, typeof(FlexigridData));
                     foreach (Helpers.FlexigridRow row in flexiGrid.rows) {
                         DeepBlue.Models.Entity.DealClosingCostType dealClosingType = new DeepBlue.Models.Entity.DealClosingCostType();
                         dealClosingType.DealClosingCostTypeID = Convert.ToInt32(row.cell[0]);
                         dealClosingType.Name = Convert.ToString(row.cell[1]);
                         dealClosingCostTypes.Add(dealClosingType);
                     }
                 }
                 else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return dealClosingCostTypes;
 }
예제 #2
0
        public override void Setup()
        {
            base.Setup();

            // Spin up mock repository and attach to controller
            MockService = new Mock<IDealClosingCostTypeService>();

            DefaultDealClosingCostType = new DeepBlue.Models.Entity.DealClosingCostType(MockService.Object);
            MockService.Setup(x => x.SaveDealClosingCostType(It.IsAny<DeepBlue.Models.Entity.DealClosingCostType>()));
        }
예제 #3
0
 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);
 }
예제 #4
0
 private IEnumerable<ErrorInfo> Validate(DealClosingCostType dealClosingCostType)
 {
     return ValidationHelper.Validate(dealClosingCostType);
 }