Example #1
0
        public ActionResult Delete(int id)
        {
            return(Execute(() =>
            {
                var request = new DeleteHourLineRequest(id);

                RequestHandlerFactory
                .Get <DeleteHourLineRequest, ResponseBase>(request)
                .Handle();
            }));
        }
Example #2
0
        public ActionResult <TimeSheet> Post([FromBody] TimeSheet timeSheet)
        {
            return(Execute(() =>
            {
                var request = new StoreTimeSheetRequest(timeSheet);

                RequestHandlerFactory
                .Get <StoreTimeSheetRequest, ResponseBase>(request)
                .Handle();

                return timeSheet;
            }));
        }
Example #3
0
        public ActionResult <TimeSheet> Get(int id)
        {
            // TODO: Dtos something something?
            return(Execute(() =>
            {
                var request = new GetTimeSheetRequest(id);

                var response = RequestHandlerFactory
                               .Get <GetTimeSheetRequest, GetTimeSheetReponse>(request)
                               .Handle();

                return response.TimeSheet.ValueOr(() => throw new EntityNotFoundException());
            }));
        }
Example #4
0
        public void OnGet(int id)
        {
            PageTitle = "Edit Timesheet";
            Execute(() =>
            {
                var request  = new GetTimeSheetRequest(id);
                var response = RequestHandlerFactory
                               .Get <GetTimeSheetRequest, GetTimeSheetReponse>(request)
                               .Handle();

                TimeSheet = response
                            .TimeSheet
                            .ValueOr(() => throw new BusinessLogicException("Timesheet not found"));
            });
        }
Example #5
0
        public ActionResult <TimeSheet[]> Get()
        {
            var currentUser = _currentUserService.Provide();

            return(Execute(() =>
            {
                var request = new TimeSheetOverviewRequest(currentUser.Id);

                var response = RequestHandlerFactory
                               .Get <TimeSheetOverviewRequest, TimeSheetOverviewReponse>(request)
                               .Handle();

                return response.TimeSheets.ToArray();
            }));
        }
Example #6
0
        public void Get_should_return_handler_with_get_method_set()
        {
            RequestHandler requestHandler = _requestHandlerFactory.Get("nowhere");

            Assert.That(requestHandler.Method, Is.EqualTo("GET"));
        }