public ActionResult FormWithBinding(Models.House h)
 {
     if (ModelState.IsValid)
     {
         ViewBag.added = true;
         HouseDBs.AddHouse(h);
     }
     return(View());
 }
Esempio n. 2
0
        public IActionResult OnPost()
        {
            if (ModelState.IsValid)
            {
                var house = new Models.House
                {
                    Id                = Guid.NewGuid(),
                    Object            = this.House.Object,
                    ObjectDescription = this.House.ObjectDescription,
                    Longitude         = this.House.Longitude,
                    Latitude          = this.House.Latitude
                };

                _houseRepository.Create(house);
                return(RedirectToPage("/House/HouseList"));
            }

            return(Page());
        }
Esempio n. 3
0
        public async Task <Result> UpdateNameAsync(string houseId, string name)
        {
            if (string.IsNullOrEmpty(houseId))
            {
                throw new ArgumentNullException(nameof(houseId));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            Models.House house = await _houseRepository.GetByIdAsync(houseId);

            if (house == null)
            {
                return(Result.Fail("Production not exist."));
            }

            house.UpdateName(name);
            _houseRepository.Update(house);

            return(Result.Success());
        }