コード例 #1
0
        public async Task <ActionResult> Create([FromForm] TripDetailedModel collection)
        {
            try
            {
                var newTrip = await _tripComponent.CreateTrip(collection);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error - Create({collection})", collection.ToJsonString());
                return(View("Error"));
            }
        }
コード例 #2
0
        public async Task <TripDetailedModel> CreateTrip(TripDetailedModel newTrip)
        {
            var reply = await _tripclient.CreateTripAsync(new CreateTripRequest
            {
                Name        = newTrip.Name,
                Destination = newTrip.Destination,
                StartDate   = newTrip.StartDate.ToString("g"),
                EndDate     = newTrip.EndDate.ToString("g"),
                GeoLocation = newTrip.GeoLocation
            }, deadline : DateTime.UtcNow.AddSeconds(5));

            return(new TripDetailedModel
            {
                Name = reply.Name,
                Destination = reply.Destination,
                GeoLocation = reply.GeoLocation,
                EndDate = DateTime.Parse(reply.EndDate),
                StartDate = DateTime.Parse(reply.StartDate),
                TripId = reply.TripId,
                Photos = new List <ViewModels.PhotoModel>()
            });
        }