Esempio n. 1
0
        public IActionResult Add([FromBody] TripOffer offer)
        {
            if (offer.StarTime <= DateTime.Now || offer.EndTime <= DateTime.Now)
            {
                return(BadRequest("Start and end time must be in the future!"));
            }
            if (offer.StarTime >= offer.EndTime)
            {
                return(BadRequest("Start time must be after end time!"));
            }

            var domain = offer.ToDomain(destRepo);

            return(domain.Match <IActionResult>(
                       some: o => {
                repo.Add(o);
                return Ok(new TripOffer(o));
            },
                       none: msg => BadRequest(msg)
                       ));
        }