public CreatorTravelBindingModel Add(CreatorTravelBindingModel item)
        {
            //todo validate user role
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                Travel travel = Mapper.Map<Travel>(item);

                db.Travels.Add(travel);
                db.SaveChanges();

                return Mapper.Map<CreatorTravelBindingModel>(travel);
            }
        }
示例#2
0
        public IHttpActionResult PostTravel(CreatorTravelBindingModel travel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                CreatorTravelBindingModel item = tr.Add(travel);
                return Created("CreatorTravel/{id}", item);
            }
            catch (Exception e)
            {
                Logger.Instance.LogException(e, LogLevel.error);
                return BadRequest();
            }
        }