public void InvalidRotationNull()
        {
            var req = new EditTimeEntryRequest()
            {
                Rotation = null,
            };

            validator.ShouldHaveValidationErrorFor(x => x.Rotation, req);
        }
        public void InvalidStudentId()
        {
            var req = new EditTimeEntryRequest()
            {
                StudentId = 0,
            };

            validator.ShouldHaveValidationErrorFor(x => x.StudentId, req);
        }
        public void InvalidPreceptorId()
        {
            var req = new EditTimeEntryRequest()
            {
                PreceptorId = 0,
            };

            validator.ShouldHaveValidationErrorFor(x => x.PreceptorId, req);
        }
        public void InvalidHoursZero()
        {
            var req = new EditTimeEntryRequest()
            {
                Hours = 0,
            };

            validator.ShouldHaveValidationErrorFor(x => x.Hours, req);
        }
        public void InvalidDateInPast()
        {
            var req = new EditTimeEntryRequest()
            {
                Date = new DateTime(1999, 1, 1).ToString(),
            };

            validator.ShouldHaveValidationErrorFor(x => x.Date, req);
        }
        public async Task <TimeEntryResponse> EditTimeEntryAsync(EditTimeEntryRequest req)
        {
            var entry  = _mapper.Map(req);
            var result = _repo.Update(entry);
            await _repo.UnitOfWork.SaveChangesAsync();

            var confirmResult = await _repo.GetEntryAsync(req.Id);

            return(_mapper.Map(confirmResult));
        }
예제 #7
0
        public TimeEntry Map(EditTimeEntryRequest req)
        {
            if (req == null)
            {
                return(null);
            }

            return(new TimeEntry()
            {
                Id = req.Id,
                Date = DateTime.Parse(req.Date),
                Hours = req.Hours,
                Notes = req.Notes,
                Rotation = req.Rotation,
                StudentId = req.StudentId,
                TeacherId = req.StudentId,
            });
        }