public ActionResult Register(Candidates candidate) { if (ModelState.IsValid) { using (OurDBContext db = new OurDBContext()) { db.candidateAccount.Add(candidate); db.SaveChanges(); } //send a registration email once changes are saved in the database CustomEmail regMail = new CustomEmail(); regMail.sendMail(candidate.Email, "Select International Registration", "Welcome to our platform!"); ModelState.Clear(); ViewBag.Message = candidate.FirstName + "" + candidate.LastName + "registration done"; //sending request to external vendor and other XML part handled here //if this is successful, need to make changes in UploadFileController too //should we do this async? using (OurDBContext db = new OurDBContext()) { Candidates cand1 = db.candidateAccount.Single(g => g.UserName == candidate.UserName); string clientCode = cand1.Requestor; Client client = db.clientAccount.Find(clientCode); RequestController rc = new RequestController(); rc.AssessmentOrderRequest(clientCode, client.ProviderKey, client.CustomerNumber, "test01", candidate.UserID, client.CallBackUri, candidate.LastName, candidate.FirstName, candidate.Email); } } return(View()); }
public ActionResult Register(Candidates candidate) { if (ModelState.IsValid) { // New workflow: // 1. Send XML request and check OK or Not, get urls info // 2. Store all info(candidatw) + urls // 3. Configure email content and send // 4. Need to this in batch register as well string id = candidate.UserID; //tianyi's code is filled here. //List<string> urls = new List<string>(); //urls.Add("http1"); //urls.Add("http2"); //urls.Add("http3"); // Sending XML request and retieve urls using (var db = new OurDBContext()) { var client = db.clientAccount.Find(candidate.Requestor); if (client != null) { var request = new RequestController(); ReturnType returnType = request.AssessmentOrderRequest(client, candidate, "Test pool 1", "None call back"); db.candidateAccount.Add(candidate); db.candidateProgressList.Add(new CandidateProgress { ReciptID = returnType.ReceiptId, UserID = id, AssessmentURL = returnType.Url, Progress = "0" //initialize progress as 0 }); db.SaveChanges(); //var progress = db.candidateProgressList.Last(); //Console.Write("URL: "+progress.AssessmentURL); //send a registration email once changes are saved in the database CustomEmail regMail = new CustomEmail(); StringBuilder mailMessage = new StringBuilder(); mailMessage.Append("Hi, " + candidate.FirstName + ":\n"); mailMessage.Append("Welcome to our platform! The followings are the assessments you need to take:\n"); mailMessage.Append(returnType.Url + "\n"); mailMessage.Append("Good Luck!"); regMail.sendMail(candidate.Email, "Select International Registration", mailMessage.ToString()); ModelState.Clear(); ViewBag.Message = candidate.FirstName + "" + candidate.LastName + "registration done"; } } } return(View()); }