public ValidationFailure ReferencesValidate(DealerSaucer dealerSaucer, ValidationContext <DealerSaucer> context) { var dealer = _dealerRepository.FindBy(dealerSaucer.DealerId); if (dealer.IsNull() || dealer.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("DealerSaucer", "El distribuidor esta desactivado o no existe")); } var saucer = _saucerRepository.FindBy(dealerSaucer.SaucerId); if (saucer.IsNull() || saucer.Status.Equals(GlobalConstants.StatusDeactivated)) { return(new ValidationFailure("DealerSaucer", "El platillo esta desactivado o no existe")); } var dealerSaucerRetrieved = _dealerSaucerRepository.FindBy(deaSau => deaSau.DealerId == dealerSaucer.DealerId && deaSau.SaucerId == dealerSaucer.SaucerId); if (dealerSaucerRetrieved.IsNotEmpty()) { return(new ValidationFailure("DealerSaucer", "Ya existe la relacion")); } return(null); }
public SuccessResponse RemoveSaucer(RelationRequest request) { try { var dealerSaucer = _dealerSaucerRepository.FindBy(dealerSaucerRe => dealerSaucerRe.DealerId == request.FirstReference && dealerSaucerRe.SaucerId == request.SecondReference).FirstOrDefault(); dealerSaucer.ThrowExceptionIfRecordIsNull(); _dealerSaucerRepository.Remove(dealerSaucer); return(new SuccessResponse { IsSuccess = true }); } catch (DataAccessException) { throw new ApplicationException(); } }