public ActionResult Create() { var model = new CreateEstateModel(); return View(model); }
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(); }
/// <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; }