Ejemplo n.º 1
0
        public bool RemoveSpecialtyFromFavorite(string userId, int specialtyId)
        {
            User_Specialty remove = this.context.User_Specialty.First(x => x.Specialty.Id == specialtyId && x.User.Id == userId);

            this.context.User_Specialty.Remove(remove);
            this.context.SaveChanges();
            return(true);
        }
Ejemplo n.º 2
0
        public bool AddSpecialtyToFavorite(string UserId, int specialtyId)
        {
            User_Specialty add = new User_Specialty();

            add.Specialty = this.context.Specialties.Where(x => x.Id == specialtyId).First();
            add.User      = this.context.Users.Where(x => x.Id == UserId).First();
            //this.context.User_Specialty.Contains(add);
            var rez = this.context.User_Specialty.Where(x => x.Specialty.Id == specialtyId && x.User.Id == UserId).FirstOrDefault();

            if (rez != null)
            {
                return(false);
            }
            this.context.User_Specialty.Add(add);
            this.context.SaveChanges();
            return(true);
        }