Add project files.
This commit is contained in:
		
							
								
								
									
										114
									
								
								Core.Blueprint.DAL.Service/SampleItemService.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								Core.Blueprint.DAL.Service/SampleItemService.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,114 @@ | ||||
| using Core.Blueprint.DAL.Infrastructure.Contracts; | ||||
| using Core.Blueprint.DAL.Service.Contracts; | ||||
| using Core.Blueprint.Domain.Entities; | ||||
| using Serilog; | ||||
|  | ||||
|  | ||||
| namespace Core.Blueprint.DAL.Service | ||||
| { | ||||
|     //[LoggingAttribute] | ||||
|     public class SampleItemService : ISampleItemService | ||||
|     { | ||||
|         private readonly ILogger _logger; | ||||
|         private readonly IRepositoryIdentityBase<SampleItem> _repository; | ||||
|         public SampleItemService(ISampleItemRepository repository, ILogger logger) | ||||
|         { | ||||
|             _repository = repository; | ||||
|             _logger = logger; | ||||
|         } | ||||
|  | ||||
|         //[LoggingAttribute] //Time of request, class name, class method... memory usage.... | ||||
|         public virtual async ValueTask<SampleItem> CreateAsync(SampleItem entity) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _logger.Information("Starting to create the Sample item"); | ||||
|                 var ret = await _repository.CreateAsync(entity); | ||||
|                 _logger.Information("Finishing to create the Sample item | Method: {method} | Class: {class}", nameof(CreateAsync), nameof(SampleItemService)); | ||||
|                 return ret; | ||||
|  | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  | ||||
|                 _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(CreateAsync), nameof(SampleItemService)); | ||||
|                 return default; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public virtual async ValueTask<bool> DeleteAsync(string id) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _logger.Information("Starting to delete the Sample item | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(SampleItemService)); | ||||
|                 var ret = await _repository.DeleteAsync(id); | ||||
|                 _logger.Information("Finishing to delete the Sample item | Method: {method} | Class: {class}", nameof(DeleteAsync), nameof(SampleItemService)); | ||||
|                 return ret; | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  | ||||
|                 _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(DeleteAsync), nameof(SampleItemService)); | ||||
|                 return default; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public virtual async ValueTask<IEnumerable<SampleItem>> GetAllAsync() | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _logger.Information("Starting to get all Sample item | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(SampleItemService)); | ||||
|                 var ret = await _repository.GetAllAsync(); | ||||
|                 _logger.Information("Finishing to get all Sample item | Method: {method} | Class: {class}", nameof(GetAllAsync), nameof(SampleItemService)); | ||||
|                 return ret; | ||||
|  | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  | ||||
|                 _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetAllAsync), nameof(SampleItemService)); | ||||
|                 return default; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public virtual async ValueTask<SampleItem> GetByIdAsync(string id) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _logger.Information("Starting to get Sample item by id | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(SampleItemService)); | ||||
|                 var ret = await _repository.GetByIdAsync(id); | ||||
|                 _logger.Information("Finishing to get all Sample item | Method: {method} | Class: {class}", nameof(GetByIdAsync), nameof(SampleItemService)); | ||||
|                 return ret; | ||||
|  | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(GetByIdAsync), nameof(SampleItemService)); | ||||
|                 return default; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public virtual async Task<bool> UpdateAsync(string id, SampleItem entity) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 _logger.Information("Starting to update Sample item  | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(SampleItemService)); | ||||
|                 var ret = await _repository.UpdateAsync(id, entity); | ||||
|                 _logger.Information("Finishing to update Sample item | Method: {method} | Class: {class}", nameof(UpdateAsync), nameof(SampleItemService)); | ||||
|                 return ret; | ||||
|  | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|  | ||||
|                 _logger.Error(ex, "{error} | Method: {method} | Class: {class}", ex.Message, nameof(UpdateAsync), nameof(SampleItemService)); | ||||
|                 return default; | ||||
|             } | ||||
|  | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin