public MainResponse RemoveHorse(int HorseId, string actionBy)
        {
            var horse = _horseRepository.GetSingle(x => x.HorseId == HorseId && x.IsDeleted == false);

            if (horse != null)
            {
                var getExhibitorHorse = _exhibitorHorseRepository.GetAll(x => x.HorseId == HorseId && x.IsDeleted == false);
                if (getExhibitorHorse.Count != 0)
                {
                    getExhibitorHorse.ForEach(x => x.IsDeleted = true);
                    foreach (var item in getExhibitorHorse)
                    {
                        _exhibitorHorseRepository.Update(item);
                    }
                }
                var getClassHorse = _exhibitorClassRepository.GetAll(x => x.HorseId == HorseId && x.IsDeleted == false);
                if (getClassHorse.Count != 0)
                {
                    getClassHorse.ForEach(x => x.IsDeleted = true);
                    foreach (var item in getClassHorse)
                    {
                        _exhibitorClassRepository.Update(item);
                    }
                }
                horse.IsDeleted   = true;
                horse.DeletedBy   = actionBy;
                horse.DeletedDate = DateTime.Now;
                _horseRepository.Update(horse);

                _mainResponse.Success = true;
                _mainResponse.Message = Constants.HORSE_REMOVED;
            }
            else
            {
                _mainResponse.Success = false;
                _mainResponse.Message = Constants.NO_RECORD_FOUND;
            }
            return(_mainResponse);
        }
Exemple #2
0
 public void Update(int id, Models.Horse horse)
 {
     repository.Update(id, horse);
     notification.SendHorseChangedMessage(horse);
 }