Пример #1
0
        public ActionResult Edit(Guid id)
        {
            var property = _landlordService.GetPropertyDetails(id);

            var model = new PropertyAddEditModel(property);

            return View("EditProperty", model);
        }
Пример #2
0
        public ActionResult Add()
        {
            var model = new PropertyAddEditModel()
            {
                Property = new PropertyModel(),
                Address = new AddressModel()
            };

            return View("AddProperty", model);
        }
Пример #3
0
        public ActionResult Add(PropertyAddEditModel model)
        {
            if (ModelState.IsValid)
            {
                var dto = model.ToDto();
                try
                {
                    var userId = _sessionDetails.User.UserId;
                    var id = _landlordService.AddProperty(userId, dto);

                    return RedirectToAction("View", id);
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);

                    return View("AddProperty", model);
                }
            }
            else
            {
                return View("AddProperty", model);
            }
        }