public void Add(Preference p)
 {
     _context.Preferences.Add(p);
     _context.SaveChanges();
 }
        private void AddNew(UserTrait userTrait, int sequence)
        {
            bool valid =
                (_prefServices.ValidatePreference(userTrait.StrainId, userTrait.TraitId, userTrait.MinValue,
                    userTrait.MaxValue, userTrait.RangeMinValue, userTrait.RangeMaxValue, _currentUserId, PreferenceYear) ==
                 null);
            if (!valid) return;

            var p = new Preference
            {
                UserId = _currentUserId,
                Year = PreferenceYear,
                StrainId = userTrait.StrainId,
                TraitId = userTrait.TraitId,
                MinValue = userTrait.MinValue,
                MaxValue = userTrait.MaxValue,
                Comment = userTrait.Comment,
                Sequence = sequence
            };
            _prefRepository.Add(p);
        }
 public void Delete(Preference p)
 {
     _context.Preferences.Remove(p);
     _context.SaveChanges();
 }