Example #1
0
        public ActionResult Create(ApartmentCreateViewModel apartmentCreateVM)
        {
            if (ModelState.IsValid)
            {
                if (apartmentCreateVM.images.Length == 1 && apartmentCreateVM.images[0] == null)
                {
                    ModelState.AddModelError("Images", "Add minimum 1 photo");
                    return(View(apartmentCreateVM));
                }

                bool addConfirm = apartmentService.Create(apartmentCreateVM, User.Identity.GetUserId(), User.Identity.Name, Server.MapPath("~/Images"));

                if (!addConfirm)
                {
                    ModelState.AddModelError("Name", "Name already exists");
                    return(View(apartmentCreateVM));
                }

                return(RedirectToAction("Index", "Home"));
            }

            return(View(apartmentCreateVM));
        }
 public async Task <ApartmentViewModel> Create(ApartmentViewModel model)
 {
     return(await _apartmentService.Create(model));
 }