public async Task <IActionResult> Create(CreateHistoryRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _historyService.Create(request);

            if (!result.IsSuccessed)
            {
                return(BadRequest(result.Message));
            }
            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <ApiResult <bool> > Create(CreateHistoryRequest request)
        {
            var history = new History()
            {
                IdUser     = request.IdUser,
                IdCity     = request.IdCity,
                Wind       = request.Wind,
                Cloudiness = request.Cloudiness,
                Humidity   = request.Humidity,
                Pressure   = request.Pressure,
                DateCreate = DateTime.UtcNow.AddHours(7)
            };

            _context.Histories.Add(history);
            await _context.SaveChangesAsync();

            return(new ApiSuccessResult <bool>());
        }