public void SetTvarina(Tvar_ADD tvar, SingInUser User) { using (Priut db = new Priut()) { var tvUsers = db.RegUsers.FirstOrDefault(w => w.Email == User.EmailSingIn); var tvType = db.Types.FirstOrDefault(w => w.NameType == tvar.Type.NameType); var tvBreed = db.Breeds.FirstOrDefault(w => w.NameBreed == tvar.Breed.NameBreed); var tvColor = db.Colors.FirstOrDefault(w => w.NameColor == tvar.Color.NameColor); if (tvType != null) { tvar.Type = tvType; } if (tvBreed != null) { tvar.Breed = tvBreed; } if (tvColor != null) { tvar.Color = tvColor; } tvar.RegisterUser = tvUsers; db.Tvar_Add.Add(tvar); db.SaveChanges(); } }
public bool SingIn(SingInUser User) { using (Priut db = new Priut()) { bool e = db.RegUsers.ToList().Any(w => w.Email == User.EmailSingIn && w.Password == User.PasswordSingIn); return(e); } }