public string GetTimeZonesByName(string name) { ITimeZoneService service = null; try { // Create search criteria. TimeZoneSearchCriteria criteria = new TimeZoneSearchCriteria(); criteria.Name = name; // Create the service. service = AppService.Create <ITimeZoneService>(); // TODO: Need to change. UserAuthentication authentication = new UserAuthentication(); service.AppManager = authentication.AppManager; // Call service method. List <Tks.Entities.TimeZone> timeZones = service.Search(criteria); var resultList = from item in timeZones where item.IsActive = true select new { Id = item.Id, Name = item.Name, ShortName = item.ShortName }; // Serialize. JavaScriptSerializer serializer = new JavaScriptSerializer(); string timeZonesJson = serializer.Serialize(resultList); // Return the value. return(timeZonesJson); } catch { throw; } finally { // Dispose. if (service != null) { service.Dispose(); } } }
private void SearchTimeZones() { ITimeZoneService service = null; try { // Get the values. string name = txtSearchName.Value; string shortName = txtSearchShortName.Value; // Validate. this.ValidateSearchEntity(); // Create the service. service = AppService.Create <ITimeZoneService>(); service.AppManager = this.mAppManager; // Build search criteria. TimeZoneSearchCriteria criteria = new TimeZoneSearchCriteria(); criteria.Name = name; criteria.ShortName = shortName; // Invoke service method. mTimeZoneList = service.Search(criteria); if (mTimeZoneList.Count == 0) { this.ShowHideValidationMessage(true); this.HideIntialView(true); //Display a message when Data is Empty. this.divEmptyRow.InnerText = "No Data Found"; } else { this.ShowHideValidationMessage(false); this.HideIntialView(false); this.hdrGridHeader.InnerText = "List of TimeZones: (" + mTimeZoneList.Count + " found)"; } // Display the list. this.divSuccessMessage.InnerText = string.Empty; this.DisplayList(mTimeZoneList); this.DisableRefershControl(); } catch (ValidationException ex) { //Display the validation errors. StringBuilder ErrorMessage = new StringBuilder(); ErrorMessage.Append(string.Format("<table><tr><td>{0}</td></tr>", ex.Message)); foreach (string s in ex.Data.Values) { ErrorMessage.Append(string.Format("<tr><td>{0}</td></tr></table>", s.ToString())); } //Hide the Error message this.divSuccessMessage.Style.Add("display", "block"); this.divSuccessMessage.InnerHtml = ErrorMessage.ToString(); this.HideIntialView(true); //Hide List Found. this.hdrGridHeader.InnerText = string.Empty; //Disable the Refersh control this.LnkRefersh.Enabled = false; } catch { throw; } finally { //Dispose the instance. if (service != null) { service.Dispose(); } } }