示例#1
0
        public async Task <ActionResult> EditTripInfo([FromBody] TripEditDTO tripInfo)
        {
            try
            {
                if (!await _editRightsService.HasEditRights(tripInfo.TripId))
                {
                    return(BadRequest(new JsonResult("You can't currently edit this trip.")));
                }
                TripDTO result = await _tripService.EditTripInfo(tripInfo);

                await _editRightsService.ProlongEditRights(tripInfo.TripId, _redisAppSettings.EditRightsProlongedTTL);

                if (result != null)
                {
                    return(Ok(result));
                }
                return(BadRequest(new JsonResult("Trip dates are not valid.")));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }