public virtual DeleteValidation <T> Delete <T>() where T : Entity { var output = new DeleteValidation <T>(); CurrentValidation = Validate(); if (CurrentValidation.IsSuccess) { var repo = DepCon.Resolve <IRepository <T> >(); output = repo.Delete(this as T); } output.Validation = CurrentValidation; return(output); }
public virtual DeleteValidation <T> Delete(T entity) { var output = new DeleteValidation <T>() { DeleteValidationSuccesful = true }; if (DbSet.All(x => x.Id != entity.Id)) { output.DeleteValidationSuccesful = false; output.Validation.Messages.Add("No existe una entity con ese id"); } if (output.DeleteValidationSuccesful) { DbSet.Remove(entity); } return(output); }
public virtual DeleteValidation <T> Delete(T entity) { var output = new DeleteValidation <T>() { IsSuccess = true }; if (DbSet.All(x => x.Id != entity.Id)) { output.IsSuccess = false; output.Validation.Errors.Add("No existe una entity con ese id"); } if (output.IsSuccess) { DbSet.Remove(entity); DbContext.SaveChanges(); } return(output); }