Пример #1
0
        public ActionResult Change(ChangeCompanyViewModel form)
        {
            var company = _companyRepository.GetBy(form.Id);

            company.Address = form.Address;
            company.Description = form.Description;
            company.Name = form.Name;

            _companyRepository.Save(company);

            return RedirectToAction("Details", new { form.Id });
        }
Пример #2
0
        public ViewResult Change(string id)
        {
            var company = _companyRepository.GetBy(id);

            var viewModel = new ChangeCompanyViewModel
                                {
                                    Id = company.Id,
                                    Name = company.Name,
                                    Description = company.Description,
                                    Address = company.Address
                                };

            return View(viewModel);
        }
Пример #3
0
        public void ChangeComapny_post_saveCompanyInRepositpory()
        {
            repositoryMock.Setup(r => r.GetBy(It.IsAny<string>())).Returns(new Company());

            var form = new ChangeCompanyViewModel
                           {
                               Name = "Name",
                               Description = "Description",
                               Address = "Address"
                           };

            controler.Change(form);

            repositoryMock.Verify(r => r.Save(It.Is<Company>(
                    c => c.Name == form.Name &&
                         c.Description == form.Description &&
                         c.Address == form.Address
                )));
        }