コード例 #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);
        }
コード例 #2
0
ファイル: HomesService.cs プロジェクト: bomman/Sharenest
        public void UpdateHome(UpdateHomeBindingModel home)
        {
            var homeToUpdate = AutoMapper.Mapper.Map <UpdateHomeBindingModel, Home>(home);

            repository.Update(homeToUpdate);
            this.repository.Commit();
        }
コード例 #3
0
ファイル: HomesController.cs プロジェクト: bomman/Sharenest
        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));
        }
コード例 #4
0
ファイル: HomesService.cs プロジェクト: bomman/Sharenest
 public HomeEditViewModel ChangeUpdateHomeBindingModelToHomesEditViewModel(UpdateHomeBindingModel home)
 {
     return(AutoMapper.Mapper.Map <UpdateHomeBindingModel, HomeEditViewModel>(home));
 }