public void GetByName_Returns_A_Status() { Assert.Empty(StatusRepository.GetAll(QueryWithDefaultValues)); Mock.Database.InsertStatus(_status); Assert.NotNull(StatusRepository.GetByName(_status.TypeGroup.Name)); }
public void ArchiveConcept_Returns_Deleted_Concept_On_Archive_Successful() { A.CallTo(() => ConceptRepository.GetById(A <int> ._)).Returns(Mock.MockConcept(_status)); A.CallTo(() => StatusRepository.GetByName(A <string> ._)).Returns(_status); A.CallTo(() => ConceptRepository.Update(A <Concept> ._)).Returns(Mock.MockConcept(_status)); var response = Service.ArchiveConcept(0, allowedUserEmail); Assert.NotNull(response.Data); Assert.IsType <ConceptDto>(response.Data); }
public Response ArchiveConcept(int id, string usersEmail) { var updatedConcept = _conceptRepository.GetById(id); if (updatedConcept == null) { return(null); } var viewModel = new Response(); var inactiveStatus = _statusRepository.GetByName(Status.STATUS_ARCHVIED); if (inactiveStatus == null) { viewModel.Errors.TryAddModelError("errorMessage", $"Did not found \"{Status.STATUS_ARCHVIED}\" status"); return(viewModel); } updatedConcept.Status = inactiveStatus; updatedConcept.StatusId = inactiveStatus.Id; updatedConcept.DeletedBy = usersEmail; try { viewModel.Data = Mapper.Map <ConceptDto>(_conceptRepository.Update(updatedConcept)); } catch (Exception) { viewModel.Errors.TryAddModelError("errorMessage", "An database error has occured. Could not delete concept."); return(viewModel); } return(viewModel); }
public Models.Domain.Status GetByName(string name) { return(_statusRepository.GetByName(name)); }