Esempio n. 1
0
        // POST api/<controller>
        public IHttpActionResult Post([FromBody] CreateBusInfo value)
        {
            if (DB.Buses.Any(x => x.Name == value.Name && x.Model == value.Model))
            {
                return(BadRequest("Bus already exists"));
            }

            var bus = new Bus()
            {
                Name  = value.Name,
                Seats = value.Seats,
                Model = value.Model
            };

            DB.Buses.Add(bus);
            DB.SaveChanges();
            return(Create <BusInfo>(bus));
        }
Esempio n. 2
0
 public static IEndpoint Create(CreateBusInfo model) => new ApiEndpoint(BaseUri, HttpMethod.Post, model);