public MovieTypeContract CreateMovieType(MovieTypeContract contract) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new MovieTypeDal(context); var process = new MovieTypeProcess(provider); var service = new MovieTypeService(process); var result = service.Create(new MovieType(contract)); var returnResult = new MovieType().ConvertToContract(result, new MovieTypeContract()); return returnResult; } } catch (Exception exception) { return HandleExceptionResponse<MovieType, MovieTypeContract>(exception); } }
public DomainListContract<MovieTypeContract> SaveAllMovieTypes(DomainListContract<MovieTypeContract> contract) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new MovieTypeDal(context); var process = new MovieTypeProcess(provider); var service = new MovieTypeService(process); var domainList = new MovieType().ConvertToDomain<MovieType, IEnumerable<MovieType>, MovieTypeContract>(contract); var result = service.SaveAll(domainList); var returnResult = new MovieType().ConvertToContract<MovieType, IEnumerable<MovieType>, MovieTypeContract>(result); return returnResult; } } catch (Exception exception) { return HandleExceptionResponse<MovieTypeContract>(exception); } }
public DomainStatusContract RemoveMovieType(int id) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new MovieTypeDal(context); var process = new MovieTypeProcess(provider); var service = new MovieTypeService(process); var result = service.Remove(id); return DomainStatus.ConvertToContract(result); } } catch (Exception exception) { return HandleExceptionResponse(exception); } }