public void UpdateTimespanNoName()
        {
            HelpdeskFacade helpdeskFacade = new HelpdeskFacade();

            AddTimeSpanRequest addTimeSpanRequest = new AddTimeSpanRequest()
            {
                HelpdeskId = 1,
                StartDate  = DateTime.Today,
                EndDate    = DateTime.Today.AddYears(1),
                Name       = AlphaNumericStringGenerator.GetString(10)
            };

            AddTimeSpanResponse addTimeSpanResponse = helpdeskFacade.AddTimeSpan(addTimeSpanRequest);

            Assert.AreEqual(HttpStatusCode.OK, addTimeSpanResponse.Status);

            UpdateTimeSpanRequest updateTimespanRequest = new UpdateTimeSpanRequest()
            {
                StartDate = new DateTime(2019, 01, 01),
                EndDate   = new DateTime(2019, 06, 01),
            };

            UpdateTimeSpanResponse updateTimespanResponse = helpdeskFacade.UpdateTimeSpan(addTimeSpanResponse.SpanId, updateTimespanRequest);

            Assert.AreEqual(HttpStatusCode.BadRequest, updateTimespanResponse.Status);
        }
        public IActionResult UpdateTimeSpan([FromRoute] int id, [FromBody] UpdateTimeSpanRequest request)
        {
            if (!IsAuthorized())
            {
                return(Unauthorized());
            }

            try
            {
                var facade   = new HelpdeskFacade();
                var response = facade.UpdateTimeSpan(id, request);

                switch (response.Status)
                {
                case HttpStatusCode.OK:
                    return(Ok(response));

                case HttpStatusCode.BadRequest:
                    return(BadRequest(BuildBadRequestMessage(response)));

                case HttpStatusCode.InternalServerError:
                    return(StatusCode(StatusCodes.Status500InternalServerError));

                case HttpStatusCode.NotFound:
                    return(NotFound());
                }
                s_logger.Fatal("This code should be unreachable, unknown result has occured.");
            }
            catch (Exception ex)
            {
                s_logger.Error(ex, "Unable to update timespan.");
            }
            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
        public void UpdateTimespanNotFound()
        {
            HelpdeskFacade helpdeskFacade = new HelpdeskFacade();

            UpdateTimeSpanRequest updateTimespanRequest = new UpdateTimeSpanRequest()
            {
                Name      = AlphaNumericStringGenerator.GetString(10),
                StartDate = new DateTime(2019, 08, 01),
                EndDate   = new DateTime(2019, 11, 01)
            };

            UpdateTimeSpanResponse updateTimespanResponse = helpdeskFacade.UpdateTimeSpan(-1, updateTimespanRequest);

            Assert.AreEqual(HttpStatusCode.NotFound, updateTimespanResponse.Status);
        }