Exemple #1
0
        public void Edit_NullValue_ShouldUpdateRightModel()
        {
            UpdateHomeBindingModel model = new UpdateHomeBindingModel()
            {
                Id           = 2,
                Name         = "New home",
                Activities   = "interesting things",
                EndDate      = DateTime.Now.AddDays(10),
                StartDate    = DateTime.Now.AddDays(3),
                Notes        = "No time for sleeping",
                LocationName = "Sofia",
                Country      = "Bulgaria",
                Provision    = "many drugs"
            };

            var controller = this._controller.Edit(model) as ViewResult;

            var lastUpdated = _context.Homes.FirstOrDefault(home => home.Id == model.Id);

            Assert.IsNotNull(lastUpdated);
            //Assert.AreEqual(lastUpdated.Id, model.Id);
            //Assert.AreEqual(lastUpdated.Name, model.Name);
            //Assert.AreEqual(lastUpdated.Location.LocationName, model.LocationName);
            //Assert.AreEqual(lastUpdated.Location.Country, model.Country);
        }
Exemple #2
0
        public void UpdateHome(UpdateHomeBindingModel home)
        {
            var homeToUpdate = AutoMapper.Mapper.Map <UpdateHomeBindingModel, Home>(home);

            repository.Update(homeToUpdate);
            this.repository.Commit();
        }
Exemple #3
0
        public ActionResult Edit([Bind(Include = "Id,Name,Country,LocationName,Activities,Provision,Notes,StartDate,EndDate")] UpdateHomeBindingModel home)
        {
            if (ModelState.IsValid)
            {
                this.service.UpdateHome(home);
                return(RedirectToAction("Index"));
            }

            var viewModel = this.service.ChangeUpdateHomeBindingModelToHomesEditViewModel(home);

            return(View(viewModel));
        }
Exemple #4
0
 public HomeEditViewModel ChangeUpdateHomeBindingModelToHomesEditViewModel(UpdateHomeBindingModel home)
 {
     return(AutoMapper.Mapper.Map <UpdateHomeBindingModel, HomeEditViewModel>(home));
 }