Exemple #1
0
        public CreateGigResponseMessage Handle(CreateGigRequestMessage request)
        {
            if (!_validator.Validate(request))
            {
                return(new CreateGigResponseMessage(request.Label,
                                                    request.Description,
                                                    request.Pickup,
                                                    request.Destination,
                                                    request.Bounty,
                                                    $"Validation failed for request",
                                                    false));
            }
            ;

            var gig = new Gig(request.Label, request.Description, request.Pickup, request.Destination, request.Bounty, request.UserId);

            _repo.Insert(gig);

            var response = new CreateGigResponseMessage(gig.Label,
                                                        gig.Description,
                                                        request.Pickup,
                                                        request.Destination,
                                                        request.Bounty,
                                                        "Success",
                                                        true);

            return(response);
        }