public void InvalidRotationNull() { var req = new AddTimeEntryRequest() { Rotation = null, }; validator.ShouldHaveValidationErrorFor(x => x.Rotation, req); }
public void InvalidStudentId() { var req = new AddTimeEntryRequest() { StudentId = 0, }; validator.ShouldHaveValidationErrorFor(x => x.StudentId, req); }
public void InvalidPreceptorId() { var req = new AddTimeEntryRequest() { PreceptorId = 0, }; validator.ShouldHaveValidationErrorFor(x => x.PreceptorId, req); }
public void InvalidHoursZero() { var req = new AddTimeEntryRequest() { Hours = 0, }; validator.ShouldHaveValidationErrorFor(x => x.Hours, req); }
public void InvalidDateInPast() { var req = new AddTimeEntryRequest() { Date = new DateTime(1999, 1, 1).ToString(), }; validator.ShouldHaveValidationErrorFor(x => x.Date, req); }
public async Task <TimeEntryResponse> AddTimeEntryAsync(AddTimeEntryRequest req) { var entry = _mapper.Map(req); var result = _repo.Add(entry); await _repo.UnitOfWork.SaveChangesAsync(); //TODO: Look for all confirm results, and hopefully one day get rid of them //the add is not linking the foreign key objects.... var confirmResult = await _repo.GetEntryAsync(result.Id); return(_mapper.Map(confirmResult)); }
public async Task <bool> AddTimeEntry(AddTimeEntryRequest entry) { var json = JsonConvert.SerializeObject(entry, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DateFormatString = "yyyy-MM-dd" }); var result = await _httpClient.PostAsync("time_entries.json", new StringContent(json, Encoding.UTF8, "application/json")); var whatwentwrong = await result.Content.ReadAsStringAsync(); return(result.IsSuccessStatusCode); }
public TimeEntry Map(AddTimeEntryRequest req) { if (req == null) { return(null); } return(new TimeEntry() { Date = DateTime.Parse(req.Date), Hours = req.Hours, Notes = req.Notes, Rotation = req.Rotation, StudentId = req.StudentId, TeacherId = req.PreceptorId, }); }