Example #1
0
        public IList<Sponsor> GetSponsors(int eventId)
        {
            using (var db = new CC.Data.CCDB())
            {
                var e = db.Events.Find(eventId);

                if (e == null)
                    throw new ArgumentException("Event not found");

                var result = new List<Sponsor>();
                // results.Add(new Sponsor { ID = 1, Name = "Microsoft" });
                // results.Add(new Sponsor { ID = 2, Name = "DevExpress" });

                foreach (var s in e.Sponsors.OrderBy(sp => Guid.NewGuid()))
                {
                    Sponsor sponsor = new Sponsor();

                    Mapper.CopyProperties(s, sponsor);

                    result.Add(sponsor);
                }

                return result;
            }
        }
Example #2
0
        public Sponsor GetSponsor(int id)
        {
            using (var db = new CC.Data.CCDB())
            {
                var sponsor = db.Sponsors.Find(id);

                Sponsor result = new Sponsor();

                Mapper.CopyProperties(sponsor, result);

                return result;
            }
        }
Example #3
0
        public void UpdateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                var s = db.Sponsors.Find(sponsor.ID);

                s.Name = sponsor.Name;
                s.Description = sponsor.Description;
                s.WebsiteUrl = sponsor.WebsiteUrl;
                s.SponsorshipLevel = sponsor.SponsorshipLevel;
                //s.ImageUrl = sponsor.ImageUrl;
                s.Image = sponsor.Image;

                db.SaveChanges();
            }
        }
Example #4
0
        public void CreateSponsor(Sponsor sponsor)
        {
            using (var db = new CC.Data.CCDB())
            {
                db.Sponsors.Add(sponsor.Map());

                db.SaveChanges();
            }
        }
Example #5
0
        public static Sponsor Map(this Data.Sponsor s)
        {
            Sponsor sponsor = new Sponsor
            {
                ID = s.ID,
                EventID = s.Event_ID,
                Name = s.Name,
                Description = s.Description,
                WebsiteUrl = s.WebsiteUrl,
                SponsorshipLevel = s.SponsorshipLevel,
                //ImageUrl = s.ImageUrl
            };

            return sponsor;
        }