コード例 #1
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            if (model == null || !this.ModelState.IsValid)
            {
                if (model == null)
                {
                    return(this.BadRequest("Game cannot be empty"));
                }

                return(this.BadRequest(this.ModelState));
            }

            var newRealEstate = this.realEstates.CreateRealEstate(
                model.Title,
                model.Description,
                model.Address,
                model.Contact,
                model.ConstructionYear,
                model.SellingPrice,
                model.RentingPrice,
                model.Type);

            var result = Mapper.Map <PublicRealEstatesResponseModel>(newRealEstate);

            return(this.Created(string.Format("/api/RealEstates/{0} ", newRealEstate.Id), result));
        }
コード例 #2
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            var newRealEstate = this.realEstates.CreateRealEstate(
                model.Title,
                model.Description,
                model.Address,
                model.Contact,
                model.ConstructionYear,
                this.User.Identity.GetUserId(),
                model.Type,
                model.SellingPrice,
                model.RentingPrice);

            if (newRealEstate == null)
            {
                return(this.BadRequest("Each estate must have selling price, renting price or both!"));
            }

            var resultingRealEstate = this.realEstates.GetRealEstateDetails(newRealEstate.Id)
                                      .ProjectTo <CreatedRealEstateResponseModel>()
                                      .FirstOrDefault();

            return(this.Created(string.Empty, resultingRealEstate));
        }
コード例 #3
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            var realEstate = this.realEstates.CreateRealEstate(
                model.Title,
                model.Description,
                model.Address,
                model.Contact, model.ConstructionYear,
                model.SellingPrice,
                model.RentingPrice,
                model.RealEstateType,
                this.User.Identity.GetUserId());

            var realEstateResult = this.realEstates
                                   .GetRealEstateDetails(realEstate.Id)
                                   .ProjectTo <BaseRealEstateResponseModel>()
                                   .FirstOrDefault();

            var location = string.Format("api/realestates/{0}", realEstate.Id);

            return(this.Created(location, realEstateResult));
        }
コード例 #4
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            if (model.SellingPrice == null && model.RentingPrice == null)
            {
                return(this.BadRequest("Real estate can be published only for renting, only for selling or for both, but not without any of the two options!"));
            }

            int realEstateId = this.realEstatesServices.Create(
                model.Title,
                model.Description,
                model.Address,
                model.Contact,
                model.ConstructionYear,
                model.SellingPrice,
                model.RentingPrice,
                (RealEstateType)model.Type,
                this.User.Identity.GetUserId());

            var response = realEstatesServices.GetById(realEstateId)
                           .ProjectTo <BaseRealEstateResponseModel>()
                           .FirstOrDefault();

            return(this.Created(string.Format("api/RealEstates/{0}", realEstateId), response));
        }
コード例 #5
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            var userId = this.User.Identity.GetUserId();

            var createdRealEstate = this.realEstates.CreateRealEstate(model.Title, model.Description, model.Address, model.Contact, model.ConstructionYear, model.SellingPrice, model.RentingPrice, model.RealEstateBuildingType, model.RealEstateContractType, userId);

            return this.Created
                (
                    string.Format("api/RealEstate/{0}", createdRealEstate.Id),
                    Mapper.Map<CreateRealEstateResponseModel>(createdRealEstate)
                );
        }
コード例 #6
0
        public IHttpActionResult Post(CreateRealEstateRequestModel model)
        {
            if (model.SellingPrice == null && model.RentingPrice == null)
            {
                return this.BadRequest("Real estate can be published only for renting, only for selling or for both, but not without any of the two options!");
            }

            int realEstateId = this.realEstatesServices.Create(
                model.Title,
                model.Description,
                model.Address,
                model.Contact,
                model.ConstructionYear,
                model.SellingPrice,
                model.RentingPrice,
                (RealEstateType)model.Type,
                this.User.Identity.GetUserId());

            var response = realEstatesServices.GetById(realEstateId)
                .ProjectTo<BaseRealEstateResponseModel>()
                .FirstOrDefault();

            return this.Created(string.Format("api/RealEstates/{0}", realEstateId), response);
        }