Ejemplo n.º 1
0
        public void UpdateIndustry(IndustryViewModel model)
        {
            try
            {
                var user = _userForAuditingRepository.GetSystemUser();

                ChecklistTemplate template = _industryRepository.GetById(model.Id);
                template.Name = model.Title;
                template.Draft = model.Draft;
                template.CreatedBy = user;
                template.CreatedOn = DateTime.Now;
                template.LastModifiedBy = user;
                template.LastModifiedOn = DateTime.Now;

                //template.Deleted
                //template.questions

                _industryRepository.SaveOrUpdate(template);
            }
            catch (Exception ex)
            {
                LogManager.GetLogger(typeof(IndustryController)).Error(ex);
                throw;
            }
        }
Ejemplo n.º 2
0
        public void Given_industry_When_update_industry_is_called_Then_industry_values_are_updated()
        {
            var industry = new ChecklistTemplate() { Id = Guid.NewGuid(), Name = "ChecklistTemplate 1", Draft = true};

            _industryRepository
                  .Setup(x => x.GetById(industry.Id))
                  .Returns(() => industry);

            ChecklistTemplate updatedTemplate = null;
            _industryRepository
                .Setup(x => x.SaveOrUpdate( It.IsAny<ChecklistTemplate>()))
                .Callback(
                    delegate(ChecklistTemplate x)
                    {
                        updatedTemplate = x;
                    }
                );

            var controller = GetTarget();

            IndustryViewModel model = new IndustryViewModel()
                                          {
                                              Id = industry.Id,
                                              Draft = false,
                                              Title = "Updated Title"
                                          };

            controller.UpdateIndustry(model);

            Assert.That(updatedTemplate.Id, Is.EqualTo(model.Id));
            Assert.That(updatedTemplate.Name, Is.EqualTo(model.Title));
            Assert.That(updatedTemplate.Draft, Is.EqualTo(model.Draft));
        }