public void AddPet(Pets p) { var dbContext = new AquanautDBContext(); dbContext.Pets.Add(p); dbContext.SaveChanges(); }
public void updatePet(Pets p) { var dbContext = new AquanautDBContext(); var pet = dbContext.Pets.FirstOrDefault(x => x.Id == p.Id); pet.IsAvailable = 0; dbContext.SaveChanges(); }
public bool validateUser(Users u) { try { var dbContext = new AquanautDBContext(); var user = dbContext.Users.FirstOrDefault(x => x.Password == x.Password && x.Userid == u.Userid); return(user != null ? true : false); } catch (Exception ex) { Startup.Logger?.Error($"Error getting Pet {ex.Message}"); throw; } }
public List <Pets> GetUserPets(int id) { var dbContext = new AquanautDBContext(); var data = (from pet in dbContext.Pets.Where(x => x.OwnerId == id.ToString()) select new Pets { Name = pet.Name, Age = pet.Age, Place = pet.Place, OwnerId = pet.OwnerId }).ToList(); return(data); }
public bool addUser(Users u) { try { var dbContext = new AquanautDBContext(); var userExists = dbContext.Users.FirstOrDefault(x => x.Userid == u.Userid); if (userExists == null) { dbContext.Users.Add(u); dbContext.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { Startup.Logger?.Error($"Error getting Pet {ex.Message}"); throw; } }
public List <Pets> GetAllPets() { var dbContext = new AquanautDBContext(); return(dbContext.Pets.ToList()); }