public Tuple <PatrimonyViewModel, IReadOnlyCollection <Notification> > Update(PatrimonyViewModel viewModel) { var entity = _mapper.Map <Patrimony>(viewModel); if (entity.Valid) { var brand = _brandService.GetById(entity.BrandId); if (brand != null) { Patrimony entityDb = _patrimonyRepository.GetById(entity.Id); if (entityDb != null) { entity.setNumberTumble(entityDb.NumberTumble); _patrimonyRepository.Update(entity); } CommandResponse commandResponse = _unitOfWork.Commit(); if (!commandResponse.Success) { entity.AddNotification("", "Erro ao salvar"); } } else { entity.AddNotification("Brand", "Marca nao cadastrada"); } } AddNotifications(entity.Notifications); return(new Tuple <PatrimonyViewModel, IReadOnlyCollection <Notification> >(_mapper.Map <PatrimonyViewModel>(entity), entity.Notifications)); }
public void GivenAnInvalidNameShouldReturnANotification() { var patrimony = new Patrimony("", "Desc 1", _brand); Assert.IsFalse(patrimony.Valid); }
public void GivenAnInvalidDescritionShouldReturnANotification() { var patrimony = new Patrimony("Teste", "D", _brand); Assert.IsFalse(patrimony.Valid); }
public void GivenAValidPatrimonyShouldCreateValidPatrimony() { var patrimony = new Patrimony("Patrominio 1", "Desc 1", _brand); Assert.IsTrue(patrimony.Valid); }