private void SaveArtifactToDatabase(List <JazzArtifact> artifacts, IbmUrlModel model) { ; foreach (var a in artifacts) { IbmArtifact artifact = new IbmArtifact() { IbmId = a.IbmId, Name = a.Name, Url = a.Url, WorkproductId = model.WorkProductId }; context.Workproduct.Where(w => w.Id == model.WorkProductId).FirstOrDefault().IbmArtifact.Add(artifact); } context.SaveChanges(); }
public IActionResult GetTasksFromIBM([FromBody] IbmUrlModel model) { string xml; List <TaskModel> nodesInXml = null; using (WebClient client = new WebClient()) { ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; String username = model.Name; String password = model.Password; String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); client.Headers.Add("Authorization", "Basic " + encoded); xml = client.DownloadString(model.Url); nodesInXml = XmlParser.CreateTaskObjects(xml); SaveToDatabase(nodesInXml, model.ProjectId); return(Ok()); } }