public void ToEntity()
        {
            var model = new TableDescViewModel()
            {
                Description = "Test",
                Id          = 1
            };

            var result = model.Validate();

            Assert.False(result.Any());

            var entity = model.GetEntity();

            Assert.Equal(model.Description, entity.Description);
            Assert.Equal(model.Id, entity.Id);
        }
Esempio n. 2
0
 public IActionResult Edit(long id, [Bind("Id,Description")] TableDescViewModel viewModel)
 {
     if (ModelState.IsValid && viewModel != null && id == viewModel.Id)
     {
         try
         {
             _tableRepository.Update(viewModel.GetEntity()).Wait();
         }
         catch (Exception)
         {
             if (_tableRepository.Exists(viewModel.Id).Result)
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(viewModel));
 }