public GenreTypeContract CreateGenreType(GenreTypeContract contract) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new GenreTypeDal(context); var process = new GenreTypeProcess(provider); var service = new GenreTypeService(process); var result = service.Create(new GenreType(contract)); var returnResult = new GenreType().ConvertToContract(result, new GenreTypeContract()); return returnResult; } } catch (Exception exception) { return HandleExceptionResponse<GenreType, GenreTypeContract>(exception); } }
public DomainListContract<GenreTypeContract> SaveAllGenreTypes(DomainListContract<GenreTypeContract> contract) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new GenreTypeDal(context); var process = new GenreTypeProcess(provider); var service = new GenreTypeService(process); var domainList = new GenreType().ConvertToDomain<GenreType, IEnumerable<GenreType>, GenreTypeContract>(contract); var result = service.SaveAll(domainList); var returnResult = new GenreType().ConvertToContract<GenreType, IEnumerable<GenreType>, GenreTypeContract>(result); return returnResult; } } catch (Exception exception) { return HandleExceptionResponse<GenreTypeContract>(exception); } }
public DomainStatusContract RemoveGenreType(int id) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new GenreTypeDal(context); var process = new GenreTypeProcess(provider); var service = new GenreTypeService(process); var result = service.Remove(id); return DomainStatus.ConvertToContract(result); } } catch (Exception exception) { return HandleExceptionResponse(exception); } }