public void Create_StartAndEndAreOnSameDays_ReturnsExpectedResourcePlan() { // Arrange DateTime startAt = DateTime.UtcNow; DateTime endAt = DateTime.UtcNow.AddDays(-1); ResourcePlan expected = new ResourcePlan { EmployeeId = FakeEmployeeId, From = startAt, To = endAt }; // Act ResourcePlan actual = ResourcePlan.Create(FakeEmployeeId, FakeEmployeeDepartment, startAt, endAt); // Assert actual.ShouldEqual(expected); }
public async Task<IHttpActionResult> PostResourcePlan(ResourcePlan resourcePlan) { if (!ModelState.IsValid) { return BadRequest(ModelState); } var existingResourcePlans = DocumentDBRepository<ResourcePlan>.GetAllItems(); if (ResourcePlanOverlapping.HasOverlapping(resourcePlan, existingResourcePlans)) { return new BadRequestErrorMessageResult( string.Format( "New resource plan starting on {0} would overlap with existing resource plan for employee {1}", resourcePlan.From, resourcePlan.EmployeeId), this); } await DocumentDBRepository<ResourcePlan>.CreateItemAsync(resourcePlan); return Created("api/resourceplans/{id}", new {id = resourcePlan.Id}); }