public async override Task <TripModel> CreateTrip(CreateTripRequest request, ServerCallContext context) { try { var newTrip = await _tripComponent.CreateTrip(new Business.Models.TripModel { Name = request.Name, Destination = request.Destination, EndDate = System.DateTime.Parse(request.EndDate), GeoLocation = request.GeoLocation, Photos = new List <Business.Models.PhotoModel>(), StartDate = System.DateTime.Parse(request.StartDate), TripId = Guid.NewGuid().ToString() }); var reply = _mapper.Map <Business.Models.TripModel, TripModel>(newTrip); return(reply); } catch (Exception ex) { _logger.LogError(ex, "CreateTrip({request})", request); throw new RpcException(new Status(StatusCode.Internal, "Internal Error")); } }
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")); } }