public async void CoordinatesCreationAsync() { var coordsRep = new CoordinatesRepository(); var usersRep = new UsersRepository(); var user = await usersRep.CreateAsync(101); var coords = new Coordinates { UserId = user.Id, Date = DateTime.Now }; var putCount = await coordsRep.PutAsync(coords); try { Assert.That(putCount, Is.EqualTo(1)); Assert.That(coords.Id, Is.GreaterThan(0)); var getted = await coordsRep.GetAsync(user.Name); Assert.That(getted.Length, Is.EqualTo(1)); Assert.That(getted[0].Id, Is.EqualTo(coords.Id)); } finally { var count = coordsRep.Remove(coords); Assert.That(count, Is.EqualTo(1)); usersRep.Remove(user); } }
public IHttpActionResult History([FromBody] HistoryCoordinatesDto requetsDto) { if (requetsDto == null) { return(BadRequest("Не передан необходимый параметр.")); } try { var coords = _rep.GetAsync(requetsDto.UserName, requetsDto.StartDate, requetsDto.EndDate).Result; var coordsDto = coords.Select(Mapper.Map <CoordinatesDto>).ToArray(); Logger.Trace("Запрошена история."); return(Ok(coordsDto)); } catch (Exception ex) { Logging.Logger.Error("Ошибка получения координат.", ex); return(InternalServerError()); } }