示例#1
0
        public string UpdateEvent(Event show)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    var showForUpdate = data.Events.Where(x => x.EventId == show.EventId).FirstOrDefault();

                    if (showForUpdate == null)
                    {
                        throw new Exception("Event not found");
                    }

                    showForUpdate.Venue    = show.Venue;
                    showForUpdate.Time     = show.Time;
                    showForUpdate.Date     = show.Date;
                    showForUpdate.Info     = show.Info;
                    showForUpdate.Url      = show.Url;
                    showForUpdate.Location = show.Location;

                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        public string UpdatePost(Blog blog)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    var blogForUpdate = data.Blogs.Where(x => x.BlogId == blog.BlogId).FirstOrDefault();

                    if (blogForUpdate == null)
                    {
                        throw new Exception("Event not found");
                    }

                    blogForUpdate.Text = blog.Text;
                    blogForUpdate.Date = blog.Date;

                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public string CreateEvent(Event show)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    data.Events.Add(show);
                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
        public string CreatePost(Blog blog)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    data.Blogs.Add(blog);
                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        public string DeleteEvent(Event show)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    var showToDelete = data.Events.Where(x => x.EventId == show.EventId).Single();
                    data.Events.Remove(showToDelete);
                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#6
0
        public string DeletePost(Blog blog)
        {
            try
            {
                using (var data = new revocarr_RiadosaOrgEntities())
                {
                    var blogToDelete = data.Blogs.Where(x => x.BlogId == blog.BlogId).Single();
                    data.Blogs.Remove(blogToDelete);
                    data.SaveChanges();
                }

                return("success");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#7
0
        public ActionResult SubmitEmail(MailingListRequest request)
        {
            if (!ModelState.IsValid)
            {
                //write code to update student

                return(View("MailingList", new MailingList()));
            }


            using (var data = new revocarr_RiadosaOrgEntities())
            {
                var existing = data.Contacts.Where(x => x.Email == request.emailAddress).SingleOrDefault();

                if (existing != null)
                {
                    ModelState.Clear();
                    return(View("MailingList", new MailingList {
                        SuccessMessage = $"{request.emailAddress} saved."
                    }));
                }

                data.Contacts.Add(new Contact
                {
                    Email     = request.emailAddress,
                    DateAdded = DateTime.Now
                });
                data.SaveChanges();
            }

            var email = new EmailProvider();

            email.SendEmail(new SendEmailRequest {
                ToAddress = "*****@*****.**", ToName = "Chief", Subject = "MailingList Submission", Body = $"New email address for the MailingList: {request.emailAddress}"
            });

            var model = new MailingList {
                SuccessMessage = $"{request.emailAddress} saved. Thanks for subscribing."
            };

            ModelState.Clear();
            return(View("MailingList", model));
        }