public override void Setup() { base.Setup(); // Spin up mock repository and attach to controller MockService = new Mock<IReportingTypeService>(); DefaultReportingType = new DeepBlue.Models.Entity.ReportingType(MockService.Object); MockService.Setup(x => x.SaveReportingType(It.IsAny<DeepBlue.Models.Entity.ReportingType>())); }
public ActionResult UpdateReportingType(FormCollection collection) { EditReportingTypeModel model=new EditReportingTypeModel(); ResultModel resultModel=new ResultModel(); this.TryUpdateModel(model); string ErrorMessage=ReportingTypeAvailable(model.Reporting,model.ReportingTypeId); if(String.IsNullOrEmpty(ErrorMessage)==false) { ModelState.AddModelError("Name",ErrorMessage); } if(ModelState.IsValid) { ReportingType reportingType=AdminRepository.FindReportingType(model.ReportingTypeId); if(reportingType==null) { reportingType=new ReportingType(); reportingType.CreatedBy=Authentication.CurrentUser.UserID; reportingType.CreatedDate=DateTime.Now; } reportingType.Reporting=model.Reporting; reportingType.Enabled=model.Enabled; reportingType.EntityID=Authentication.CurrentEntity.EntityID; reportingType.LastUpdatedBy=Authentication.CurrentUser.UserID; reportingType.LastUpdatedDate=DateTime.Now; IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveReportingType(reportingType); if(errorInfo!=null) { resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo); } else { resultModel.Result="True||"+reportingType.ReportingTypeID; } } 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); }
private IEnumerable<ErrorInfo> Validate(ReportingType reportingtype) { return ValidationHelper.Validate(reportingtype); }
public static List<DeepBlue.Models.Entity.ReportingType> GetReportingTypesFromDeepBlue(CookieCollection cookies) { List<DeepBlue.Models.Entity.ReportingType> reportingTypes = new List<DeepBlue.Models.Entity.ReportingType>(); // GET: /Admin/UnderlyingList // Send the request string url = HttpWebRequestUtil.GetUrl("Admin/ReportingTypeList?pageIndex=1&pageSize=50&sortName=Reporting&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.ReportingType rType = new DeepBlue.Models.Entity.ReportingType(); rType.ReportingTypeID = Convert.ToInt32(row.cell[0]); rType.Reporting = Convert.ToString(row.cell[1]); reportingTypes.Add(rType); } } else { } response.Close(); readStream.Close(); } } } return reportingTypes; }