Example #1
0
 public static List<DeepBlue.Models.Entity.Geography> GetGeographiesFromDeepBlue(CookieCollection cookies)
 {
     List<DeepBlue.Models.Entity.Geography> geographies = new List<DeepBlue.Models.Entity.Geography>();
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/GeographyList?pageIndex=1&pageSize=50&sortName=Geography1&sortOrder=");
     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.Geography geography = new DeepBlue.Models.Entity.Geography();
                         geography.GeographyID = Convert.ToInt32(row.cell[0]);
                         geography.Geography1 = Convert.ToString(row.cell[1]);
                         geographies.Add(geography);
                     }
                 } else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return geographies;
 }
Example #2
0
 public ActionResult UpdateGeography(FormCollection collection)
 {
     EditGeographyModel model=new EditGeographyModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=GeographyAvailable(model.Geography,model.GeographyId);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("Name",ErrorMessage);
     }
     if(ModelState.IsValid) {
         Geography geography=AdminRepository.FindGeography(model.GeographyId);
         if(geography==null) {
             geography=new Geography();
             geography.CreatedBy=Authentication.CurrentUser.UserID;
             geography.CreatedDate=DateTime.Now;
         }
         geography.Geography1=model.Geography;
         geography.Enabled=model.Enabled;
         geography.EntityID=Authentication.CurrentEntity.EntityID;
         geography.LastUpdatedBy=Authentication.CurrentUser.UserID;
         geography.LastUpdatedDate=DateTime.Now;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveGeography(geography);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True";
         }
     } 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);
 }
Example #3
0
 private IEnumerable<ErrorInfo> Validate(Geography geography)
 {
     return ValidationHelper.Validate(geography);
 }