Exemplo n.º 1
0
        public void DeleteUnit(int unitId)
        {
            ApartmentsDbContext con = new ApartmentsDbContext();
            Unit unit = con.Units.FirstOrDefault(unit => unit.Id == unitId);

            con.Units.Remove(unit);
            con.SaveChanges();
        }
Exemplo n.º 2
0
        public void DeleteGroup(int groupId)
        {
            ApartmentsDbContext con       = new ApartmentsDbContext();
            UnitGroup           unitGroup = con.UnitGroups.FirstOrDefault(unitGroup => unitGroup.Id == groupId);

            con.UnitGroups.Remove(unitGroup);
            con.SaveChanges();
        }
Exemplo n.º 3
0
        public static void SetUserIdByApplicationUser(ApplicationUser applicationUser)
        {
            var dbContext = new ApartmentsDbContext();

            //TODO Metoda z repa, pokud zustanou dve DB
            var user = dbContext.Users.FirstOrDefault(usr => usr.Username == applicationUser.UserName);

            if (user == null) // does not exist yet
            {
                user = new User
                {
                    Username = applicationUser.UserName,
                    Email    = applicationUser.Email,
                    IsAdmin  = false,
                    Password = "******"
                };

                dbContext.Users.Add(user);
                dbContext.SaveChanges();
            }

            UserId = user.Id;
        }
 public bool SaveChanges()
 {
     return(_context.SaveChanges() >= 0);
 }
Exemplo n.º 5
0
 public void Insert(Apartment entity)
 {
     _context.Apartments.Add(entity);
     _context.SaveChanges();
 }