Esempio n. 1
0
        public override void Setup()
        {
            base.Setup();

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

            DefaultIndustry = new DeepBlue.Models.Entity.Industry(MockService.Object);
            MockService.Setup(x => x.SaveIndustry(It.IsAny<DeepBlue.Models.Entity.Industry>()));
        }
Esempio n. 2
0
 public ActionResult UpdateIndustry(FormCollection collection)
 {
     EditIndustryModel model=new EditIndustryModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=IndustryNameAvailable(model.Industry,model.IndustryId);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("Name",ErrorMessage);
     }
     if(ModelState.IsValid) {
         Industry industry=AdminRepository.FindIndustry(model.IndustryId);
         if(industry==null) {
             industry=new Industry();
             industry.CreatedBy=Authentication.CurrentUser.UserID;
             industry.CreatedDate=DateTime.Now;
         }
         industry.Industry1=model.Industry;
         industry.EntityID=Authentication.CurrentEntity.EntityID;
         industry.Enabled=model.Enabled;
         industry.LastUpdatedBy=Authentication.CurrentUser.UserID;
         industry.LastUpdatedDate=DateTime.Now;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveIndustry(industry);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True||"+industry.IndustryID;
         }
     } 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);
 }
Esempio n. 3
0
 private IEnumerable<ErrorInfo> Validate(Industry industry)
 {
     return ValidationHelper.Validate(industry);
 }
Esempio n. 4
0
 public static List<DeepBlue.Models.Entity.Industry> GetIndustriesFromDeepBlue(CookieCollection cookies)
 {
     List<DeepBlue.Models.Entity.Industry> industries = new List<DeepBlue.Models.Entity.Industry>();
     // GET: /Admin/UnderlyingList
     // Send the request
     string url = HttpWebRequestUtil.GetUrl("Admin/IndustryList?pageIndex=1&pageSize=50&sortName=Industry1&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.Industry industry = new DeepBlue.Models.Entity.Industry();
                         industry.IndustryID = Convert.ToInt32(row.cell[0]);
                         industry.Industry1 = Convert.ToString(row.cell[1]);
                         industries.Add(industry);
                     }
                 } else {
                 }
                 response.Close();
                 readStream.Close();
             }
         }
     }
     return industries;
 }