示例#1
0
        public async void UpdateProjectWorkAsync()
        {
            var project = EntitiesFactory.NewProject(developerIds: new[] { SessionDeveloper.Id }).Save();
            var work    = EntitiesFactory.NewWork(Guid.NewGuid(), project.DeveloperProjects.Single().Id).Save();
            var workDto = new WorkClientDto
            {
                Id        = work.Id,
                StartTime = DateTime.Now.AddHours(-3),
                EndTime   = DateTime.Now.AddHours(-1),
                Comment   = RandomHelper.RandomString(105),
                Hours     = 30
            };

            var(status, result) = await Request.PutAsync <ResultTest>(new Uri($"{Uri}/{project.Id}/works/{work.Id}"), workDto);

            var workDb = await DbContext.Works
                         .Include(w => w.DeveloperProject)
                         .FirstAsync(w => w.Id == workDto.Id);

            await DbContext.Entry(workDb).ReloadAsync();

            Assert.Equal(Status.Success, status);
            Assert.NotNull(workDb.DeveloperProject);
            Assert.Equal(project.Id, workDb.DeveloperProject.ProjectId);
            Assert.Equal(SessionDeveloper.Id, workDb.DeveloperProject.DeveloperId);
            Assert.Equal(workDto.StartTime, workDb.StartTime, TimeSpan.FromSeconds(5));
            Assert.Equal(workDto.EndTime, workDb.EndTime, TimeSpan.FromSeconds(5));
            Assert.Equal(workDto.Comment, workDb.Comment);
            Assert.Equal(workDto.Hours, workDb.Hours);
        }
 public async Task <Result> UpdateWorkProjectAsync([FromBody] WorkClientDto workDto, [FromRoute] Guid workId)
 {
     workDto.Id = workId;
     return(GetResult(await _workService.UpdateWorkAsync(new WorkUpdateDto(workDto))));
 }
        public async Task <Result> CreateWorkProjectAsync([FromBody] WorkClientDto workDto, [FromRoute] Guid id)
        {
            var workCreateDto = new WorkCreateDto(workDto, id, _context.Id);

            return(GetResult(await _workService.CreateWorkAsync(workCreateDto)));
        }