public PolicyResponse GetOnePolicy(Policy policy) { PolicyResponse response = new PolicyResponse(); response.NewPolicy = IsValidCheck.IsValidPolicyLookup(policy); if (response.NewPolicy.isValid == false) { response.Message = "An error occurred"; response.Success = false; } else { response.NewPolicy = _categoryRepository.GetPolicy(policy); response.Success = true; } return(response); }
public CategoryResponse GetOneCategory(string name) { CategoryResponse response = new CategoryResponse(); response.NewCategory.Name = name; response.NewCategory = IsValidCheck.IsValidCategory(response.NewCategory); if (response.NewCategory.isValid == false) { response.Message = "An error has occurred"; response.Success = false; } else { response.NewCategory = _categoryRepository.Get(name); response.Success = true; } return(response); }
public PolicyResponse AddNewPolicy(Policy policy) { PolicyResponse response = new PolicyResponse(); response.NewPolicy = IsValidCheck.IsValidPolicy(policy); if (response.NewPolicy.isValid == false) { response.Message = "Name and content must be provided"; response.Success = false; } else if (!_categoryRepository.AddPolicy(policy)) { response.Message = "An error has occurred"; response.Success = false; } else { response.Success = true; } return(response); }
public CategoryResponse AddNewCategory(Category category) { CategoryResponse response = new CategoryResponse(); response.NewCategory = IsValidCheck.IsValidCategory(category); if (response.NewCategory.isValid == false) { response.Message = "A name must be provided"; response.Success = false; } else if (!_categoryRepository.AddCategory(category)) { response.Message = "An error has occurred"; response.Success = false; } else { response.Success = true; } return(response); }
public CategoryResponse DeleteCategory(string categoryName) { CategoryResponse response = new CategoryResponse(); response.NewCategory.Name = categoryName; response.NewCategory = IsValidCheck.IsValidCategory(response.NewCategory); if (response.NewCategory.isValid == false) { response.Message = "An error has occurred"; response.Success = false; } else if (!_categoryRepository.DeleteCategory(categoryName)) { response.Message = "An error has occurred"; response.Success = false; } else { response.Success = true; } return(response); }