コード例 #1
0
 public List <Models.HologramType> GetAll()
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.HologramType.ToList());
     }
 }
コード例 #2
0
 public User Get(string username, string password)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.User.FirstOrDefault(u => u.UserName == username && u.Password == password));
     }
 }
コード例 #3
0
 public HologramEvent Get(string name)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.HologramEvent.FirstOrDefault(u => u.Name == name));
     }
 }
コード例 #4
0
 public User Get(int userId)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.User.FirstOrDefault(u => u.UserId == userId));
     }
 }
コード例 #5
0
 public List <User> Get(string username)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.User.Where(u => u.UserName == username).ToList());
     }
 }
コード例 #6
0
 public CelebrityIndustry Get(string name)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.CelebrityIndustry.FirstOrDefault(u => u.Name == name));
     }
 }
コード例 #7
0
 public List <CelebrityIndustry> Get()
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.CelebrityIndustry.ToList());
     }
 }
コード例 #8
0
 public List <CelebrityGroup> Get()
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.CelebrityGroup.ToList());
     }
 }
コード例 #9
0
 public Celebrity Get(int id)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.Celebrity.FirstOrDefault(u => u.CelebrityId == id));
     }
 }
コード例 #10
0
 public HologramEvent Get(int id)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.HologramEvent.FirstOrDefault(u => u.HologramEventId == id));
     }
 }
コード例 #11
0
 public Celebrity Get(string firstname, string lastname, string middlename)
 {
     using (var c = new CelebrityHologramContext())
     {
         return(c.Celebrity.FirstOrDefault(u => u.FirstName == firstname &&
                                           u.LastName == lastname && u.MiddleName == middlename));
     }
 }
コード例 #12
0
 public CelebrityGroup Update(CelebrityGroup celebGroup)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.CelebrityGroup.Update(celebGroup);
         var id = c.SaveChanges();
         return(celebGroup);
     }
 }
コード例 #13
0
 public int Save(CelebrityGroup celebGroup)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.CelebrityGroup.Add(celebGroup);
         c.SaveChanges();
         return(celebGroup.CelebrityGroupId);
     }
 }
コード例 #14
0
 public int Save(User user)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.User.Add(user);
         c.SaveChanges();
         return(user.UserId);
     }
 }
コード例 #15
0
 public Celebrity Update(Celebrity celeb)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.Celebrity.Update(celeb);
         var id = c.SaveChanges();
         return(celeb);
     }
 }
コード例 #16
0
 public int Save(Celebrity celeb)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.Celebrity.Add(celeb);
         c.SaveChanges();
         return(celeb.CelebrityId);
     }
 }
コード例 #17
0
 public HologramEvent Update(HologramEvent hEvent)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.HologramEvent.Update(hEvent);
         var id = c.SaveChanges();
         return(hEvent);
     }
 }
コード例 #18
0
 public int Save(HologramEvent hEvent)
 {
     using (var c = new CelebrityHologramContext())
     {
         c.HologramEvent.Add(hEvent);
         c.SaveChanges();
         return(hEvent.HologramEventId);
     }
 }
コード例 #19
0
        public static void Seed(CelebrityHologramContext context)
        {
            //context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            if (!context.User.Any())
            {
                context.User.Add(
                    new Models.User
                {
                    CreatedBy   = "Suhas",
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    Password    = "******",
                    UpdatedBy   = "Suhas",
                    UserName    = "******"
                });
                context.User.Add(
                    new Models.User
                {
                    CreatedBy   = "Suhas",
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    Password    = "******",
                    UpdatedBy   = "Suhas",
                    UserName    = "******"
                });
            }

            if (!context.HologramType.Any())
            {
                context.HologramType.Add(new Models.HologramType
                {
                    CreatedBy   = "Suhas",
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    UpdatedBy   = "Suhas",
                    Description = "Light is shone through the hologram",
                    Name        = "Transmission"
                });

                context.HologramType.Add(new Models.HologramType
                {
                    CreatedBy   = "Suhas",
                    DateCreated = DateTime.Now,
                    DateUpdated = DateTime.Now,
                    UpdatedBy   = "Suhas",
                    Description = "The hologram reflects light",
                    Name        = "Reflection "
                });
            }

            context.SaveChanges();
        }
コード例 #20
0
        public void Delete(int id)
        {
            using (var c = new CelebrityHologramContext())
            {
                var celeb = Get(id);

                if (celeb != null)
                {
                    celeb.Deleted = true;
                    Update(celeb);
                }
            }
        }
コード例 #21
0
        public void Delete(int id)
        {
            using (var c = new CelebrityHologramContext())
            {
                var hEvent = Get(id);

                if (hEvent != null)
                {
                    hEvent.Deleted = true;
                    Update(hEvent);
                }
            }
        }
        public List <CelebrityHologramSearch> Get()
        {
            using (var c = new CelebrityHologramContext())
            {
                var responses = (from ch in c.CelebrityHologram
                                 join h in c.HologramEvent on ch.HologramEventId equals h.HologramEventId
                                 join cl in c.Celebrity on ch.CelebrityId equals cl.CelebrityId
                                 select new CelebrityHologramSearch
                {
                    HologramEvents = h,
                    Holograms = ch,
                    Celebrity = cl
                }

                                 ).ToList();

                return(responses);
            }
        }
        public CelebrityHologramSearch Get(int celebrityHologramId)
        {
            using (var c = new CelebrityHologramContext())
            {
                var response = (from ch in c.CelebrityHologram
                                join h in c.HologramEvent on ch.HologramEventId equals h.HologramEventId
                                join cl in c.Celebrity on ch.CelebrityId equals cl.CelebrityId
                                where ch.CelebrityHologramId == celebrityHologramId
                                select new CelebrityHologramSearch
                {
                    HologramEvents = h,
                    Holograms = ch,
                    Celebrity = cl
                }

                                ).FirstOrDefault();

                return(response);
            }
        }
コード例 #24
0
        public static void Migrate()
        {
            var context = new CelebrityHologramContext();

            ContextSeeder.Seed(context);
        }