Exemplo n.º 1
0
        public ActionResult Edit(EditModel editModel, HttpPostedFileBase imageFile)
        {
            IEnumerable <PropertyType> propertyTypes = propertyBL.GetPropertyType();

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

            if (imageFile != null && imageFile.ContentLength > 0)
            {
                var fileName = Path.GetFileName(imageFile.FileName);
                var path     = Path.Combine(Server.MapPath("~/App_Data/Images"), fileName);
                imageFile.SaveAs(path);
            }
            if (ModelState.IsValid)
            {
                editModel.PropertyModel.Image = new byte[imageFile.ContentLength];
                imageFile.InputStream.Read(editModel.PropertyModel.Image, 0, imageFile.ContentLength);
                property = AutoMapper.Mapper.Map <PropertyModel, Property>(editModel.PropertyModel);
                Dictionary <int, int> propertyValues = new Dictionary <int, int>();
                FeatureKey = GetFeatureValues(editModel.PropertyModel.PropertyId);
                for (int index = 0; index < FeatureKey.Count; index++)
                {
                    propertyValues.Add(FeatureKey[index], editModel.FeatureValues[index]);
                }
                propertyBL.UpdatePropertyDetails(property, propertyValues);
                return(RedirectToAction("DisplayPropertyDetails"));
            }
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult Edit(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);
                propertyBL.UpdatePropertyDetails(property);
                return(RedirectToAction("DisplayPropertyDetails"));
            }
            return(View());
        }