Ejemplo n.º 1
0
        public string GetLocation(int id = 0)
        {
            eLocalDataContext db = new eLocalDataContext();
            LocationWithServices loc = new LocationWithServices();
            JavaScriptSerializer js = new JavaScriptSerializer();

            loc = (from l in db.Locations
                   where l.locationID.Equals(id)
                   select new LocationWithServices {
                       locationID = l.locationID,
                       name = l.name,
                       phone = l.phone,
                       fax = l.fax,
                       email = l.email,
                       address = l.address,
                       city = l.city,
                       state = (from st in db.States where st.stateID.Equals(l.stateID) select st.abbr).FirstOrDefault<string>(),
                       stateID = l.stateID,
                       zip = Convert.ToInt32(l.zip),
                       isPrimary = l.isPrimary,
                       latitude = l.latitude,
                       longitude = l.longitude,
                       places_status = l.places_status,
                       places_reference = l.places_reference,
                       places_id = l.places_id,
                       services = (from s in db.Services join ls in db.Location_Services on s.serviceID equals ls.serviceID where ls.locationID.Equals(id) select s).ToList<Service>()
                   }).FirstOrDefault<LocationWithServices>();
            return js.Serialize(loc);
        }
Ejemplo n.º 2
0
        //
        // GET: /Locator/
        public ActionResult Index()
        {
            eLocalDataContext db = new eLocalDataContext();
            JavaScriptSerializer js = new JavaScriptSerializer();

            List<LocationWithServices> locations = (from l in db.Locations
                                                 select new LocationWithServices {
                                                    locationID = l.locationID,
                                                    name = l.name,
                                                    phone = l.phone,
                                                    fax = l.fax,
                                                    email = l.email,
                                                    address = l.address,
                                                    city = l.city,
                                                    state = db.States.Where(x => x.stateID == l.stateID).Select(x => x.abbr).FirstOrDefault<string>(),
                                                    zip = Convert.ToInt32(l.zip),
                                                    isPrimary = l.isPrimary,
                                                    latitude = l.latitude,
                                                    longitude = l.longitude,
                                                    places_status = l.places_status,
                                                    places_reference = l.places_reference,
                                                    places_id = l.places_id,
                                                    services = (from s in db.Services
                                                                join ls in db.Location_Services on s.serviceID equals ls.serviceID
                                                                where ls.locationID.Equals(l.locationID)
                                                                select s).ToList<Service>()
                                                 }).ToList<LocationWithServices>();
            ViewBag.locations = locations;
            ViewBag.locations_json = js.Serialize(locations);
            ViewBag.states = APIModels.GetStates();

            return View();
        }
Ejemplo n.º 3
0
        public static List<Archive> GetMonths()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                List<Archive> archives = new List<Archive>();

                archives = (from p in db.Posts
                            where p.publishedDate.Value != null && p.publishedDate.Value <= DateTime.Now && p.active.Equals(true)
                            orderby p.publishedDate.Value.Year descending, p.publishedDate.Value.Month descending
                            select new Archive
                            {
                                monthnum = Convert.ToInt16(Convert.ToDateTime(p.publishedDate).Month.ToString()),
                                month = Convert.ToDateTime(p.publishedDate).Month.ToString(),
                                year = Convert.ToDateTime(p.publishedDate).Year.ToString()
                            }).Distinct().ToList<Archive>();

                archives = (from a in archives
                            orderby a.year descending, a.monthnum
                            select a).Distinct().ToList<Archive>();

                return archives;
            } catch {
                return new List<Archive>();
            }
        }
Ejemplo n.º 4
0
 public static List<Video> GetOurVideos()
 {
     try {
         eLocalDataContext db = new eLocalDataContext();
         return db.Videos.OrderBy(x => x.dateAdded).ToList<Video>();
     } catch (Exception) {
         return new List<Video>();
     }
 }
Ejemplo n.º 5
0
        //
        // GET: /About/
        public ActionResult Index()
        {
            // Get the About Us content entry for the database
            SiteContent about_content = new SiteContent();
            eLocalDataContext db = new eLocalDataContext();
            about_content = db.SiteContents.Where(x => x.page_title == "About").FirstOrDefault<SiteContent>();
            ViewBag.content = about_content;

            return View();
        }
Ejemplo n.º 6
0
        public static List<Gallery> GetImages()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();

                return db.Galleries.OrderBy(x => x.sort_order).ToList<Gallery>();
            } catch (Exception) {
                return new List<Gallery>();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the location record for the given location ID
        /// </summary>
        /// <param name="id">Location ID</param>
        /// <returns>Location</returns>
        public static Location GetLocation(int id = 0)
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                Location loc = new Location();

                loc = db.Locations.Where(x => x.locationID == id).FirstOrDefault<Location>();
                return loc;
            } catch (Exception e) {
                return new Location();
            }
        }
Ejemplo n.º 8
0
        public static Company Get()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();

                Company comp = (from c in db.Companies
                                select c).FirstOrDefault<Company>();
                return comp;
            } catch (Exception e) {
                return new Company();
            }
        }
Ejemplo n.º 9
0
 public static SiteContent GetHomeContent()
 {
     try {
         eLocalDataContext db = new eLocalDataContext();
         SiteContent home = db.SiteContents.Where(x => x.page_title == "Home").FirstOrDefault<SiteContent>();
         if (home == null) {
             home = new SiteContent();
         }
         return home;
     } catch (Exception) {
         return new SiteContent();
     }
 }
Ejemplo n.º 10
0
        public static eLocal.Category GetCategoryByName(string name = "")
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                eLocal.Category category = new eLocal.Category();

                category = db.Categories.Where(x => x.name == name).FirstOrDefault<eLocal.Category>();

                return category;
            } catch {
                return new eLocal.Category();
            }
        }
Ejemplo n.º 11
0
        public static eLocal.Category GetCategory(int id = 0)
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                eLocal.Category category = new eLocal.Category();

                category = db.Categories.Where(x => x.CategoryID == id).FirstOrDefault<eLocal.Category>();

                return category;
            } catch {
                return new eLocal.Category();
            }
        }
Ejemplo n.º 12
0
        public static List<eLocal.Category> GetCategories()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                List<eLocal.Category> categories = new List<eLocal.Category>();

                categories = db.Categories.Where(x => x.active == true).OrderBy(x => x.name).ToList<eLocal.Category>();

                return categories;
            } catch {
                return new List<eLocal.Category>();
            }
        }
Ejemplo n.º 13
0
        public static List<FAQ> GetAll(string sorted_column = "", string sort_direction = "")
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                List<FAQ> faqs = new List<FAQ>();

                switch (sorted_column) {
                    // Sort by question
                    case "question":
                        switch (sort_direction) {
                            case "descending":
                                faqs = db.FAQs.OrderByDescending(x => x.question).ToList<FAQ>();
                                break;
                            default:
                                faqs = db.FAQs.OrderBy(x => x.question).ToList<FAQ>();
                                break;
                        }
                        break;

                    // Sort by answer
                    case "answer":
                        switch (sort_direction) {
                            case "descending":
                                faqs = db.FAQs.OrderByDescending(x => x.answer).ToList<FAQ>();
                                break;
                            default:
                                faqs = db.FAQs.OrderBy(x => x.answer).ToList<FAQ>();
                                break;
                        }
                        break;

                    // Sort by faqID
                    default:
                        switch (sort_direction) {
                            case "descending":
                                faqs = db.FAQs.OrderByDescending(x => x.faqID).ToList<FAQ>();
                                break;
                            default:
                                faqs = db.FAQs.OrderBy(x => x.faqID).ToList<FAQ>();
                                break;
                        }
                        break;

                }

                return faqs;
            } catch (Exception e) {
                return new List<FAQ>();
            }
        }
Ejemplo n.º 14
0
        public static bool GetPage(string page_title = "")
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                SiteContent sc = new SiteContent();

                sc = db.SiteContents.Where(x => x.page_title == page_title).FirstOrDefault<SiteContent>();
                if (sc != null && sc.content_text.Length > 0) {
                    return true;
                }
                return false;
            } catch (Exception) {
                return false;
            }
        }
Ejemplo n.º 15
0
        //
        // GET: /Render/
        public ActionResult Index( string page = "")
        {
            try {
                if (page.Length == 0) { throw new Exception(""); }

                eLocalDataContext db = new eLocalDataContext();
                SiteContent content = db.SiteContents.Where(x => x.page_title == page).FirstOrDefault<SiteContent>();
                if (content.content_text.Length == 0) {
                    throw new Exception("");
                }

                ViewBag.content = content;
                return View();
            } catch (Exception e) {
                return Redirect("/");
            }
        }
Ejemplo n.º 16
0
        //
        // GET: /Contact/
        public ActionResult Index()
        {
            // get the different locations for this company

            eLocalDataContext db = new eLocalDataContext();
            List<LocationWithState> locations = new List<LocationWithState>();
            JavaScriptSerializer js = new JavaScriptSerializer();
            try {
                locations = (from l in db.Locations
                             where l.email.Length > 0
                             select new LocationWithState {
                                 locationID = l.locationID,
                                 name = l.name,
                                 email = l.email,
                                 phone = l.phone,
                                 fax = l.fax,
                                 address = l.address,
                                 city = l.city,
                                 stateID = l.stateID,
                                 state = (from s in db.States
                                          where s.stateID.Equals(l.stateID)
                                          select s.abbr).FirstOrDefault<string>(),
                                 zip = (int)l.zip,
                                 latitude = l.latitude,
                                 longitude = l.longitude,
                                 isPrimary = l.isPrimary,
                                 places_id = l.places_id,
                                 places_reference = l.places_reference,
                                 places_status = l.places_status
                             }).Distinct().OrderBy(x => x.state).ToList<LocationWithState>();
                ViewBag.locations_json = js.Serialize(locations);
            } catch (Exception e) {
                ViewBag.error = e.Message;
            }
            ViewBag.locations = locations;
            ViewBag.hide_sidebar = true;
            return View();
        }
Ejemplo n.º 17
0
        public ActionResult Comment(int id = 0, string name = "", string email = "", string comment_text = "")
        {
            Post post = PostModel.GetById(id);
            string postdate = String.Format("{0:M-d-yyyy}", post.publishedDate);
            try
            {
                if(!(ReCaptcha.Validate(privateKey: "6Levd8cSAAAAAO_tjAPFuXbfzj6l5viTEaz5YjVv")))
                {
                    throw new Exception("Recaptcha Validation Failed.");
                }
                if (id == 0) { throw new Exception("You must be on a blog post to add a comment"); }
                if (name == "") { throw new Exception("You must enter your name"); }
                if (email != "" & (!IsValidEmail(email))) { throw new Exception("Your email address is not a valid format."); }
                if (comment_text.Trim() == "") { throw new Exception("You must enter a comment"); }

                eLocalDataContext db = new eLocalDataContext();
                bool moderate = CompanyModel.Get().moderate_blog;
                eLocal.Comment comment = new eLocal.Comment
                {
                    postID = id,
                    name = name,
                    email = email,
                    comment_text = Regex.Replace(comment_text.Trim(),"<.*?>",string.Empty),
                    createdDate = DateTime.Now,
                    active = true,
                    approved = (moderate) ? false : true
                };
                db.Comments.InsertOnSubmit(comment);
                db.SubmitChanges();
                string message = "";
                if(moderate)
                    message = "Your comment has been submitted for approval.";
                return RedirectToRoute("BlogPost", new { message = message, title = post.SiteContent.page_title, date = postdate });
            } catch (Exception e) {
                return RedirectToRoute("BlogPost", new { err = e.Message, title = post.SiteContent.page_title, date = postdate, email = email, name = name, comment_text = comment_text });
            }
        }
Ejemplo n.º 18
0
        public static List<Banner> GetRandomBanners(int count = 0, bool random = false)
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                List<Banner> banners = new List<Banner>();

                if (count == 0) { // Get all the banners
                    banners = (from b in db.Banners
                               where b.starts <= DateTime.Now && b.ends >= DateTime.Now
                               select b).OrderBy(x => x.bannerID).ToList<Banner>();
                } else { // Get a specific number of banners
                    banners = (from b in db.Banners
                               where b.starts <= DateTime.Now && b.ends >= DateTime.Now
                               select b).OrderBy(x => x.bannerID).Take(count).ToList<Banner>();
                }
                if (random) {
                    banners = APIModels.Shuffle<Banner>(banners);
                }
                return banners;
            } catch (Exception e) {
                return new List<Banner>();
            }
        }
Ejemplo n.º 19
0
        public static List<Service> GetServices()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();

                return db.Services.OrderBy(x => x.service_title).ToList<Service>();
            } catch (Exception) {
                return new List<Service>();
            }
        }
Ejemplo n.º 20
0
        public static List<string> GetPrimaryLinks()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                List<string> links = new List<string>();

                links = db.SiteContents.Where(x => x.isPrimary == 1).OrderBy(x => x.page_title).Select(x => x.page_title).ToList<string>();
                return links;
            } catch (Exception) {
                return new List<string>();
            }
        }
Ejemplo n.º 21
0
        public static Location GetPrimaryLocation()
        {
            try {
                eLocalDataContext db = new eLocalDataContext();
                Location location = new Location();

                location = (from l in db.Locations
                            where l.isPrimary.Equals(1)
                            select l).FirstOrDefault<Location>();
                if (location.locationID == null || location.locationID == 0) {
                    location = db.Locations.OrderBy(x => x.locationID).FirstOrDefault<Location>();
                    if (location.locationID == null || location.locationID == 0) {
                        return new Location();
                    }
                }
                return location;
            } catch (Exception e) {
                return new Location();
            }
        }