public BorrowedItemContract CreateBorrowedItem(BorrowedItemContract contract) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new BorrowedItemDal(context); var process = new BorrowedItemProcess(provider); var service = new BorrowedItemService(process); var result = service.Create(new BorrowedItem(contract)); return new BorrowedItem().ConvertToContract(result, new BorrowedItemContract()); } } catch (Exception exception) { return HandleExceptionResponse<BorrowedItem, BorrowedItemContract>(exception); } }
public DomainListContract<BorrowedItemContract> FetchAllBorrowedItems(bool includeDeletion) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new BorrowedItemDal(context); var process = new BorrowedItemProcess(provider); var service = new BorrowedItemService(process); var result = service.GetAll(includeDeletion); var returnResult = new BorrowedItem().ConvertToContract<BorrowedItem, IEnumerable<BorrowedItem>, BorrowedItemContract>(result); return returnResult; } } catch (Exception exception) { return HandleExceptionResponse<BorrowedItemContract>(exception); } }
public DomainStatusContract RemoveBorrowedItem(int id) { try { using (var context = new MovieShelfEntities(ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString)) { var provider = new BorrowedItemDal(context); var process = new BorrowedItemProcess(provider); var service = new BorrowedItemService(process); var result = service.Remove(id); return DomainStatus.ConvertToContract(result); } } catch (Exception exception) { return HandleExceptionResponse(exception); } }