public static void AddToBidderCompletedProjectSucessPayment(int projectid, int payerid, string payerole) { var context = new SidejobEntities(); var biddercompletedprojectsucesspayment = new CompletedProjectSucessPayment { PayerID = payerid, PayerProjectRole = "BIDDER", PayerRole = payerole, ProjectID = projectid }; context.AddToCompletedProjectSucessPayment(biddercompletedprojectsucesspayment); context.SaveChanges(); //check to see if the poster has already made the payment: var posterpayment = (from c in context.CompletedProjectSucessPayment where c.ProjectID == projectid && c.PayerProjectRole == "POSTER" select c).FirstOrDefault(); if (posterpayment != null) { //poster PosterSuccessPayment(projectid, 4, posterpayment.PayerRole, posterpayment.PayerID); } }