Esempio n. 1
0
        public static HomeContentViewModel UpdateHomeContent(HomeContentViewModel content)
        {
            try
            {
                using (var dc = new PortfolioDataContext())
                {
                    var homeContent = dc.PageContents.FirstOrDefault(i => i.ContentType == (int)MenuType.Index);

                    if (homeContent == null)
                    {
                        return(null);
                    }
                    else
                    {
                        homeContent.Content = JsonConvert.SerializeObject(content);
                        dc.SubmitChanges();
                        return(content);
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 2
0
        public static HomeContentViewModel GetHomeContent()
        {
            try
            {
                using (var dc = new PortfolioDataContext())
                {
                    var homeContent = dc.PageContents.FirstOrDefault(i => i.ContentType == (int)MenuType.Index);

                    if (homeContent == null)
                    {
                        var content = new HomeContentViewModel()
                        {
                            Greeting = "Hi, I am Alex",
                            Intro    = "Software Developer"
                        };

                        return(CreateHomeContent(content));
                    }
                    else
                    {
                        return(JsonConvert.DeserializeObject <HomeContentViewModel>(homeContent.Content));
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 3
0
        public static ContactContentViewModel GetContactContent()
        {
            try
            {
                using (var dc = new PortfolioDataContext())
                {
                    var contactContent = dc.PageContents.FirstOrDefault(i => i.ContentType == (int)MenuType.Contact);

                    if (contactContent == null)
                    {
                        var content = new ContactContentViewModel()
                        {
                            HeaderText = "Contact me by calling or send me an email using the form below",
                            Phone      = "8-800-80-80",
                            Email      = "*****@*****.**",
                        };

                        return(CreateContactContent(content));
                    }
                    else
                    {
                        return(JsonConvert.DeserializeObject <ContactContentViewModel>(contactContent.Content));
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 4
0
        private static HomeContentViewModel CreateHomeContent(HomeContentViewModel content)
        {
            try
            {
                using (var db = new PortfolioDataContext())
                {
                    db.PageContents.InsertOnSubmit(new PageContent()
                    {
                        ContentType = (int)MenuType.Index,
                        Content     = JsonConvert.SerializeObject(content)
                    });
                    db.SubmitChanges();

                    return(content);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Esempio n. 5
0
        public static void SendEmail(MailMessage email)
        {
            try
            {
                using (var db = new PortfolioDataContext())
                {
                    InboxMessage message = new InboxMessage()
                    {
                        MessageFrom = email.From.ToString(),
                        Subject     = email.Subject,
                        Message     = email.Body,
                        IsChecked   = false,
                        Date        = DateTime.Now
                    };

                    db.InboxMessages.InsertOnSubmit(message);
                    db.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }