Beispiel #1
0
        public ActionResult CreateAppartment()
        {
            CreateAppartmentViewModel model = new CreateAppartmentViewModel();
            var listStreets = streetRepository.GetAll();

            model.Streets = new SelectList(listStreets, "Id", "Title");
            return(View(model));
        }
 /// <summary>
 /// Преобразование из класса CreaViewModel в объект таблицы "Квартира"
 /// </summary>
 /// <param name="appartmentViewModel">Модель с параметрами на создание объекта "Квартира"</param>
 /// <returns>Объект "Квартира"</returns>
 public static Appartment ParseCreateAppartmentViewModel(CreateAppartmentViewModel appartmentViewModel)
 {
     return(new Appartment()
     {
         StreetId = appartmentViewModel.StreetId,
         HouseNumber = appartmentViewModel.HouseNumber,
         Building = appartmentViewModel.Building,
         Flat = appartmentViewModel.Flat
     });
 }
Beispiel #3
0
        public async Task <ActionResult> CreateAppartment(CreateAppartmentViewModel model)
        {
            if (ModelState.IsValid)
            {
                var appartment = ParseCreateAppartmentViewModel(model);
                await appartmentRepository.Add(appartment);

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }