Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #21 from Soluto/fix/mongo-ignore
Browse files Browse the repository at this point in the history
ignore extra elements
  • Loading branch information
oreporan authored Nov 18, 2020
2 parents 85e8010 + ea8a3ce commit bb7e277
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Miro/Models/MiroConfig/RepoConfig.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
using System;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Miro.Models.MiroConfig
{
[BsonIgnoreExtraElements]
public class RepoConfig
{
public ObjectId Id { get; set; }
public string Owner { get; set; }
public string Repo { get; set; }
public string MergePolicy { get; set; } = "whitelist";
public string UpdateBranchStrategy { get; set; } = "oldest";
public string DefaultBranch { get; set; } = "master";
public bool Quiet { get; set; } = false;
public string UpdateBranchStrategy { get; set; } = "oldest";
public string DefaultBranch { get; set; } = "master";
public bool Quiet { get; set; } = false;
public DateTime UpdatedAt { get; set; }
}

public static class RepoConfigExt
{

public static bool IsWhitelistStrict(this RepoConfig repoConfig) => repoConfig.MergePolicy == "whitelist-strict";
public static bool IsValidMergePolicy(this RepoConfig repoConfig) => repoConfig.MergePolicy == "whitelist" ||repoConfig.MergePolicy == "whitelist-strict" || repoConfig.MergePolicy == "blacklist";
public static bool IsValidUpdateBranchStrategy(this RepoConfig repoConfig) => repoConfig.UpdateBranchStrategy == "oldest" || repoConfig.UpdateBranchStrategy == "all" || repoConfig.UpdateBranchStrategy == "none";
public static bool IsValidMergePolicy(this RepoConfig repoConfig) => repoConfig.MergePolicy == "whitelist" || repoConfig.MergePolicy == "whitelist-strict" || repoConfig.MergePolicy == "blacklist";
public static bool IsValidUpdateBranchStrategy(this RepoConfig repoConfig) => repoConfig.UpdateBranchStrategy == "oldest" || repoConfig.UpdateBranchStrategy == "all" || repoConfig.UpdateBranchStrategy == "none";
public static bool IsBlacklist(this RepoConfig repoConfig) => repoConfig.MergePolicy == "blacklist";

}
Expand Down
1 change: 1 addition & 0 deletions Miro/Services/MiroConfig/RepoConfigRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace MiroConfig
{

public class RepoConfigRepository
{
private readonly IMongoCollection<RepoConfig> collection;
Expand Down

0 comments on commit bb7e277

Please sign in to comment.