public IHttpActionResult PostOffer(OfferInputModel offerData)
        {
            if (!ModelState.IsValid || offerData == null)
            {
                return this.BadRequest(ModelState);
            }

            var currentUserId = this.User.Identity.GetUserId();
            if (currentUserId == null)
            {
                return this.Unauthorized();
            }


            var offer = new Offer()
            {
                Title = offerData.Title,
                Description = offerData.Description,
                InitialPrice = offerData.InitialPrice,
                ExpirationDate = offerData.ExpirationDateTime,
                PublishDate = DateTime.Now,
                SellerId = currentUserId
            };

            this.db.Offers.Add(offer);
            this.db.SaveChanges();

            var currentUserName = User.Identity.GetUserName();
            return this.CreatedAtRoute(
                "PostOffer",
                new { id = offer.Id },
                new { id = offer.Id, Seller = currentUserName, Message = "Offer created." });
        }
        public IHttpActionResult CrateOffer(OfferInputModel offerData)
        {
            if (offerData == null)
            {
                return BadRequest("Missing offer data.");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var currentUserId = User.Identity.GetUserId();
            var seller = this.db.UserStore.FindByIdAsync(currentUserId).Result;
            if (seller == null)
            {
                return this.Unauthorized();
            }

            var offer = new Offer()
            {
                Title = offerData.Title,
                Description = offerData.Description,
                DatePublished = DateTime.Now,
                SellerId = currentUserId,
                InitialPrice = offerData.InitialPrice,
                ExpirationDateTime = offerData.ExpirationDateTime
            };
            db.Offers.Add(offer);
            db.SaveChanges();

            return this.CreatedAtRoute("OfferDetails", 
                new { id = offer.Id},
                new { offer.Id, Seller = seller.UserName, Message = "Offer created." });
        }