public Infrastructure.ValidationError[] DeleteProdus(Guid id) { Infrastructure.ValidationError[] validationErrors = pozaValidation.DeleteProdus(id); if (validationErrors.Any()) { return(validationErrors); } pozaResource.DeleteProdus(id); return(new Infrastructure.ValidationError[0]); }
public void Delete(Guid id) { Produs produsExistent; produsExistent = databaseContext.Produs.FirstOrDefault(existingProdus => existingProdus.Id == id); if (produsExistent != null) { if (produsExistent.CaleFolder != "") { if (Directory.Exists(produsExistent.CaleFolder)) { Directory.Delete(produsExistent.CaleFolder, true); } } pozaService.DeleteProdus(produsExistent.Id); databaseContext.Attach(produsExistent); databaseContext.Produs.Remove(produsExistent); databaseContext.SaveChanges(); } }