public ActionResult Records(int?page, int?sortColumnIndex, int?sortDirection, string searchText) { RecordListModel model = new RecordListModel(); SearchAttributes searchParam = new SearchAttributes(); searchParam.CurrentPageNumber = (page.HasValue && page.Value > 0) ? page.Value : 1; searchParam.RecordsPerPage = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage); if (sortColumnIndex.HasValue) { searchParam.SortColumnIndex = sortColumnIndex.Value; } else { searchParam.SortColumnIndex = 1; } searchParam.SortDirection = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending; if (!string.IsNullOrEmpty(searchText)) { searchParam.SearchText = searchText; } model.SearchParam = searchParam; model.Populate(searchParam); //for Ajax Specific Request if (Request.IsAjaxRequest()) { return(View("~/Views/Shared/PartialViews/Admin/Record/_RecordList.cshtml", model)); } else { return(View("~/Views/Admin/Record/RecordList.cshtml", model)); } }
public ActionResult GetSectors(int?page, int?sortColumnIndex, int?sortDirection, string searchText) { ManageSectorModel SectorModel = new ManageSectorModel(); SearchAttributes searchParam = new SearchAttributes(); searchParam.CurrentPageNumber = (page.HasValue && page.Value > 0) ? page.Value : 1; searchParam.RecordsPerPage = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage); searchParam.SortColumnIndex = (sortColumnIndex.HasValue && sortColumnIndex.Value > 0) ? sortColumnIndex.Value : 1; searchParam.SortDirection = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending; if (!string.IsNullOrEmpty(searchText)) { searchParam.SearchText = searchText; } SectorModel.SearchParam = searchParam; SectorModel.GetAllSector(searchParam); //for Ajax Specific Request if (Request.IsAjaxRequest()) { return(View("~/Views/Shared/PartialViews/Admin/Sector/_SectorList.cshtml", SectorModel)); } else { return(View("~/Views/Admin/Sector/SectorList.cshtml", SectorModel)); } }
public static CheckPortResult CheckInitPort() { CheckPortResult result = new CheckPortResult() { Ok = true }; result.HttpPort = AppSettingsUtility.GetInt("Port", -1); if (result.HttpPort > 0) { // define port. if (Lib.Helper.NetworkHelper.IsPortInUse(result.HttpPort)) { string message = Data.Language.Hardcoded.GetValue("Port") + " " + result.HttpPort.ToString() + " " + Data.Language.Hardcoded.GetValue("is in use"); result.Ok = false; result.ErrorMessage = message; return(result); } } else { result.HttpPort = 80; // default port. while (Lib.Helper.NetworkHelper.IsPortInUse(result.HttpPort) && result.HttpPort < 65535) { result.HttpPort += 1; } } result.SslPort = AppSettingsUtility.GetInt("SslPort", -1); if (result.SslPort > 0) { // define port. if (Lib.Helper.NetworkHelper.IsPortInUse(result.SslPort)) { string message = Data.Language.Hardcoded.GetValue("Port") + " " + result.SslPort.ToString() + " " + Data.Language.Hardcoded.GetValue("is in use"); result.Ok = false; result.ErrorMessage = message; return(result); } } else { result.SslPort = 443; while (Lib.Helper.NetworkHelper.IsPortInUse(result.HttpPort) && result.HttpPort < 65535) { result.HttpPort += 1; } } return(result); }
/// <summary> /// Page Action Result /// </summary> /// <returns></returns> public ActionResult Pages(int?page, int?sortColumnIndex, int?sortDirection) { PageListModel model = new PageListModel(); SearchAttributes searchParam = new SearchAttributes(); searchParam.CurrentPageNumber = (page.HasValue && page.Value > 0) ? page.Value : 1; searchParam.RecordsPerPage = AppSettingsUtility.GetInt(AppSettingsKeys.RecordsPerPage); searchParam.SortColumnIndex = 1; searchParam.SortDirection = (sortDirection.HasValue && sortDirection.Value == 1) ? Entity.SortDirection.Descending : Entity.SortDirection.Ascending; model.Populate(searchParam); //for Ajax Specific Request if (Request.IsAjaxRequest()) { return(View("~/Views/Shared/PartialViews/Admin/Page/_PageList.cshtml", model)); } else { return(View("~/Views/Admin/Page/PageList.cshtml", model)); } }
/// <summary> /// Send Email /// </summary> /// <returns></returns> public bool SendMail(HttpPostedFileBase File) { bool SendMail = false; try { MailMessage mail = new MailMessage(); mail.Subject = AppSettingsUtility.GetString(AppSettingsKeys.MailSubject); mail.Body = ""; string html = System.IO.File.ReadAllText(HttpContext.Current.Server.MapPath("~/mailTemplate/MailBody.html")); mail.Body = string.Format(html, this.Contact, this.Salutation, this.FirstName, this.LastName, this.Email, this.Company, this.JobTitle, this.PhoneNumber, this.Country, this.DocumentName, this.Year, this.DocumentAvailability, this.URL, this.Comments); mail.From = new MailAddress(Email); mail.To.Add(AppSettingsUtility.GetString(AppSettingsKeys.MailTo)); if (File != null) { string fileName = Path.GetFileName(File.FileName); mail.Attachments.Add(new Attachment(File.InputStream, fileName)); } mail.IsBodyHtml = true; using (SmtpClient smtp = new SmtpClient()) { smtp.Host = AppSettingsUtility.GetString(AppSettingsKeys.SmtpHost); smtp.Port = AppSettingsUtility.GetInt(AppSettingsKeys.SmtpPort);; smtp.Send(mail); SendMail = true; } } catch (Exception ex) { ErrorLog.WriteLog("ContactUsModel", "SendEmail", ex, ""); } return(SendMail); }
public static SimpleSearchFilter GetSearchFilter(LuisResult result, string postalCode) { //Check if value exists if (PageSize <= 0) { PageSize = AppSettingsUtility.GetInt("RecordsPerPage"); MaxMileage = AppSettingsUtility.GetInt("MaxMileage"); MaxPrice = AppSettingsUtility.GetInt("MaxPrice"); SortBy = AppSettingsUtility.GetString("SortBy"); DefaultZipCode = AppSettingsUtility.GetString("DefaultZipCode"); } var filter = new SimpleSearchFilter { MinMileage = 0, MaxMileage = MaxMileage, PageNo = 1, PageSize = PageSize, MinPrice = 0, MaxPrice = MaxPrice, Radius = -1, SortBy = SortBy, SortDirection = 0, PostalCode = DefaultZipCode }; if (!string.IsNullOrEmpty(postalCode)) { filter.PostalCode = postalCode; } if (result != null && result.Entities != null && result.Entities.Count > 0) { if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_CONDITION)) { filter.StockType = result.Entities.FirstOrDefault(e => e.Type == BotConstants.LUIS_ENTITY_CONDITION).Entity; } if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_MAKE)) { filter.Make = result.Entities.FirstOrDefault(e => e.Type == BotConstants.LUIS_ENTITY_MAKE).Entity; } if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_MODEL)) { filter.Model = result.Entities.FirstOrDefault(e => e.Type == BotConstants.LUIS_ENTITY_MODEL).Entity; } if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_COLOR)) { filter.ExteriorColor = result.Entities.FirstOrDefault(e => e.Type == BotConstants.LUIS_ENTITY_COLOR).Entity; } if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_YEAR)) { filter.Year = result.Entities.FirstOrDefault(e => e.Type == BotConstants.LUIS_ENTITY_YEAR).Entity; } var priceOptions = GetPriceOptions(result); if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_PRICE_UNDER) && priceOptions.Count > 0) { filter.MaxPrice = priceOptions.OrderByDescending(p => p).FirstOrDefault(); } if (result.Entities.Any(e => e.Type == BotConstants.LUIS_ENTITY_PRICE_ABOVE) && priceOptions.Count > 0) { filter.MinPrice = priceOptions.OrderBy(p => p).FirstOrDefault(); } } return(filter); }