예제 #1
0
        public ActionResult Create(BuyerPropertyModel propertyModel, HttpPostedFileBase fileBase)
        {
            IEnumerable <PropertyType> propertyTypes = propertyBL.GetPropertyType();

            ViewBag.propertyId = new SelectList(propertyTypes, "PropertyTypeID", "Type");
            BuyerProperty property = new BuyerProperty();

            propertyModel.UserId = (int)TempData["UserId"];
            if (fileBase != null && fileBase.ContentLength > 0)
            {
                var fileName = Path.GetFileName(fileBase.FileName);
                var path     = Path.Combine(Server.MapPath("~/App_Data/Images"), fileName);
                fileBase.SaveAs(path);
            }
            if (ModelState.IsValid)
            {
                propertyModel.Image = new byte[fileBase.ContentLength];
                fileBase.InputStream.Read(propertyModel.Image, 0, fileBase.ContentLength);
                propertyModel.Status = "Reject";
                property             = AutoMapper.Mapper.Map <BuyerPropertyModel, BuyerProperty>(propertyModel);
                if (propertyBL.Create(property) > 0)
                {
                    ViewBag.Message = "Your property registration is under processed";
                }
                else
                {
                    ViewBag.Message = "failed";
                }
            }
            return(View());
        }
예제 #2
0
        public ActionResult Create(PropertyModel propertyModel)
        {
            IEnumerable <PropertyType> propertyTypes = propertyBL.GetPropertyType();

            ViewBag.propertyId = new SelectList(propertyTypes, "PropertyTypeID", "Type");
            Property property = new Property();

            if (ModelState.IsValid)
            {
                property = AutoMapper.Mapper.Map <PropertyModel, Property>(propertyModel);
                if (propertyBL.Create(property) > 0)
                {
                    TempData["TypeId"] = property;
                    return(RedirectToAction("AddFeature", "PropertyFeature"));
                }
                else
                {
                    ViewBag.Message = "failed";
                }
            }
            return(View());
        }