public IHttpActionResult Post(BountyClaimPostModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ApplicationDbContext db = new ApplicationDbContext();

            // Check to make sure the url does not already exist
            if (db.BountyClaims.Where(m => m.URL == model.Url).Count() > 0)
            {
                return(StatusCode(HttpStatusCode.Conflict));
            }

            // Add the new claim to the database
            db.BountyClaims.Add(new BountyClaim(model));

            db.SaveChanges();

            return(Ok());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor based on post model
 /// </summary>
 /// <param name="post">The model post from the front end</param>
 public BountyClaim(BountyClaimPostModel post)
 {
     Email         = post.Email;
     WalletAddress = post.Wallet;
     URL           = post.Url;
 }