Ejemplo n.º 1
0
        public ActionResult Create()
        {
            var model = new CreateEstateModel();

            return View(model);
        }
Ejemplo n.º 2
0
        public ActionResult Create(CreateEstateModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                var unit = this.MapModel(model);

                if (file != null)
                    unit.Image = this.imageService.SaveImage(file, Server.MapPath(PATH_TO_UPLOADED_FILES));

                unit.DateAdded = DateTime.Now;

                this.accountService.GetCurrentUser().GetUserDetails().AddUnit(unit);

                this.unitsRepository.Save(unit);

                return this.Create();
            }

            return this.Create();
        }
Ejemplo n.º 3
0
        /// <summary>Maps the model to entity.</summary>
        /// <param name="model">The model.</param>
        /// <returns>Mapped entity.</returns>
        private Unit MapModel(CreateEstateModel model)
        {
            var unit = new Unit();
            var address = new Address();

            Mapper.Map<CreateEstateModel, Unit>(model, unit);
            Mapper.Map<CreateEstateModel, Address>(model, address);

            unit.SetAddress(address);

            return unit;
        }