Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 3
0
        // GET: News
        public ActionResult Index()
        {
            List <Blog> blogs;

            using (var data = new revocarr_RiadosaOrgEntities())
            {
                blogs = data.Blogs.Select(x => x).OrderByDescending(x => x.Date).ToList();
            }
            return(View(blogs));
        }
Exemplo n.º 4
0
        // GET: Shows
        public ActionResult Index()
        {
            List <Event> shows;

            using (var data = new revocarr_RiadosaOrgEntities())
            {
                shows = data.Events.Select(x => x).OrderByDescending(x => x.Date).ToList();
            }

            //return View(new Shows
            //{
            //    Future = shows.Where(x => x.Date > DateTime.Now.AddDays(-1)).OrderBy(x => x.Date), Past = shows.Where(x => x.Date < DateTime.Now.AddDays(-1))  });
            return(View(shows));
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
            }
        }
        public IEnumerable <object> GetCurrentListings()
        {
            IEnumerable <Listing> Listings;

            using (var data = new revocarr_RiadosaOrgEntities())
            {
                Listings = data.Database.SqlQuery <Listing>(@"SELECT TOP (1000) 
		                                    --e.[Id]
                                              e.[Title]
                                              --,e.[MFLocationId]
                                              ,e.[URL]
                                              ,e.[AuxField]
                                              ,e.[Date]
                                              ,e.[Time]
                                              --,e.[DateTimeEntered]
                                              --,e.[Current]
	                                          ,l.Name as Location
                                          FROM [revocarr_RiadosaOrg].[revocarr_1].[MFEvent] e

                                          JOIN [revocarr_RiadosaOrg].[revocarr_1].[MFLocation] L
                                          on E.MFLocationId = L.Id

                                          WHERE e.[Current] = 1
                                          order by l.Name").ToList();
            }

            var listingsByLocation = new Dictionary <string, List <Listing> >();

            foreach (var listing in Listings)
            {
                if (!listingsByLocation.ContainsKey(listing.Location))
                {
                    listingsByLocation.Add(listing.Location, new List <Listing> {
                        listing
                    });
                }
                else
                {
                    listingsByLocation[listing.Location].Add(listing);
                }
            }

            var listingObjects = listingsByLocation.Select(x => new { name = x.Key, films = x.Value });

            return(listingObjects);
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
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;
            }
        }
Exemplo n.º 10
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));
        }