public async Task <HttpResponseMessage> Add(ICollection <IFormFile> WBFiles, WorkloadViewModel workload) { //Owner: var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value; //Complete WB fields: workload.WBCreatedBy = uniqueName; workload.WBCreatedDate = DateTime.Now; //Iterate over files: try { if (WBFiles.Count > 0) { List <Tuple <Guid, string, string> > fileList = await UploadNewFiles(WBFiles); //Adds the file lists to the workload object: workload.WBFilesList = fileList; } var response = await Util.ConnectToRemoteService(HttpMethod.Post, Util.KanbanURL + "api/workload/add", uniqueName, "", workload); if (response.IsSuccessStatusCode) { return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public ActionResult Create(WorkloadViewModel model) { if (model.NoOfIdeas <= 0 && model.NoOfEvaluators <= 0) { return(BadRequest()); } var ideas = new List <Idea>(); for (int i = 0; i < model.NoOfIdeas; i++) { ideas.Add(new Idea() { Name = "Idea - " + i, Description = "Idea Description - " + i }); } var evaluators = new List <Evaluator>(); for (int i = 0; i < model.NoOfEvaluators; i++) { evaluators.Add(new Evaluator() { Name = "Evaluator - " + i }); } _context.Ideas.AddRange(ideas); _context.Evaluators.AddRange(evaluators); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public WorkloadsView() { InitializeComponent(); string filePath = OpenManifestFile(); ViewModel = new WorkloadViewModel(filePath); this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext); }
public async Task <HttpResponseMessage> Update(ICollection <IFormFile> WBFiles, List <string> oldFiles, WorkloadViewModel workload) { //Owner: var uniqueName = HttpContext.User.Claims.First(claim => claim.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name").Value; //Update WB fields: //workload.WBCreatedBy = uniqueName; //workload.WBCreatedDate = DateTime.Now; //Iterate over files: var fileList = new List <Tuple <Guid, string, string> >(); if (WBFiles.Count > 0) { fileList = await UploadNewFiles(WBFiles); } if (oldFiles != null) { for (int i = 0; i < oldFiles.Count; i++) { var split = oldFiles[i].Split('&'); var f = new Tuple <Guid, string, string>(new Guid(split[0]), split[1], split[2]); fileList.Add(f); } } //Adds the file lists to the workload object: workload.WBFilesList = fileList; var response = await Util.ConnectToRemoteService(HttpMethod.Put, Util.KanbanURL + "api/workload/edit", uniqueName, "", workload); if (response.IsSuccessStatusCode) { return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public bool AddNewWorkload(WorkloadViewModel workload) { try { //Load related Activity: var activity = _context.Activities.First(a => a.ActivityID == workload.WBActivity); //Load related Metrics: var metricList = new List <WorkloadBacklogMetric>(); if (workload.WBMetrics != null) { foreach (var mId in workload.WBMetrics) { var metric = _context.Metrics.First(m => m.MetricID == mId); metricList.Add(new WorkloadBacklogMetric() { Metric = metric }); } } //Load related Technologies: var technologyList = new List <WorkloadBacklogTechnology>(); if (workload.WBTechnologies != null) { foreach (var tId in workload.WBTechnologies) { var technology = _context.Technologies.First(t => t.TechnologyID == tId); technologyList.Add(new WorkloadBacklogTechnology() { Technology = technology }); } } //Load related Users: var userList = new List <WorkloadBacklogUser>(); if (workload.WBUsers != null) { foreach (var uniqueName in workload.WBUsers) { var user = _context.Users.First(u => u.UniqueName == uniqueName); userList.Add(new WorkloadBacklogUser() { User = user }); } } //Associate related Files: var filesList = new List <File>(); if (workload.WBFilesList != null) { foreach (var f in workload.WBFilesList) { filesList.Add(new File() { FileID = f.Item1, FileLink = f.Item2, FileName = f.Item3, FileDescription = string.Empty, }); } } //Create workload object: var workloadToBeSaved = new WorkloadBacklog() { WBActivity = activity, WBAppointments = null, WBComplexity = (Complexity)workload.WBComplexity, WBCreatedBy = workload.WBCreatedBy, WBCreatedDate = workload.WBCreatedDate, WBDescription = workload.WBDescription, WBEndDate = workload.WBEndDate, WBExpertise = (Expertise)workload.WBExpertise, WBFiles = filesList, WBID = workload.WBID, WBIsWorkload = workload.WBIsWorkload, WBMetrics = metricList, WBStartDate = workload.WBStartDate, WBStatus = (Status)workload.WBStatus, WBTechnologies = technologyList, WBTitle = workload.WBTitle, WBUsers = userList }; _context.WorkloadBacklogs.Add(workloadToBeSaved); _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public bool EditWorkload(WorkloadViewModel workload) { try { //Get files: var files = _context.Files.Where(f => f.WorkloadBacklog.WBID == workload.WBID); //Load Metrics: var metrics = _context.WorkloadBacklogMetrics.Where(wbm => wbm.WorkloadBacklog.WBID == workload.WBID); //Load Technologies: var technologies = _context.WorkloadBacklogTechnologies.Where(wbt => wbt.WorkloadBacklog.WBID == workload.WBID); //Load Users: var users = _context.WorkloadBacklogUsers.Where(wbu => wbu.WorkloadBacklog.WBID == workload.WBID); //Remove Everything: _context.Files.RemoveRange(files); _context.WorkloadBacklogMetrics.RemoveRange(metrics); _context.WorkloadBacklogTechnologies.RemoveRange(technologies); _context.WorkloadBacklogUsers.RemoveRange(users); _context.SaveChanges(); //Load workload from DB: var workloadToBeUpdated = _context.WorkloadBacklogs.First(w => w.WBID == workload.WBID); //Load related Activity: var activity = _context.Activities.First(a => a.ActivityID == workload.WBActivity); //Load related Metrics: var metricList = new List <WorkloadBacklogMetric>(); foreach (var mId in workload.WBMetrics) { var metric = _context.Metrics.First(m => m.MetricID == mId); metricList.Add(new WorkloadBacklogMetric() { Metric = metric }); } //Load related Technologies: var technologyList = new List <WorkloadBacklogTechnology>(); foreach (var tId in workload.WBTechnologies) { var technology = _context.Technologies.First(t => t.TechnologyID == tId); technologyList.Add(new WorkloadBacklogTechnology() { Technology = technology }); } //Load related Users: var userList = new List <WorkloadBacklogUser>(); foreach (var uniqueName in workload.WBUsers) { var user = _context.Users.First(u => u.UniqueName == uniqueName); userList.Add(new WorkloadBacklogUser() { User = user }); } //Associate related Files: var filesList = new List <File>(); foreach (var f in workload.WBFilesList) { filesList.Add(new File() { FileID = f.Item1, FileLink = f.Item2, FileName = f.Item3, FileDescription = string.Empty, }); } //Update workload object: workloadToBeUpdated.WBActivity = activity; //workloadToBeUpdated.WBAppointments = null; workloadToBeUpdated.WBComplexity = (Complexity)workload.WBComplexity; //workloadToBeUpdated.WBCreatedBy = workload.WBCreatedBy; //workloadToBeUpdated.WBCreatedDate = workload.WBCreatedDate; workloadToBeUpdated.WBDescription = workload.WBDescription; workloadToBeUpdated.WBEndDate = workload.WBEndDate; workloadToBeUpdated.WBExpertise = (Expertise)workload.WBExpertise; workloadToBeUpdated.WBFiles = filesList; workloadToBeUpdated.WBID = workload.WBID; workloadToBeUpdated.WBIsWorkload = workload.WBIsWorkload; workloadToBeUpdated.WBMetrics = metricList; workloadToBeUpdated.WBStartDate = workload.WBStartDate; workloadToBeUpdated.WBStatus = (Status)workload.WBStatus; workloadToBeUpdated.WBTechnologies = technologyList; workloadToBeUpdated.WBTitle = workload.WBTitle; workloadToBeUpdated.WBUsers = userList; _context.SaveChanges(); return(true); } catch (Exception) { return(false); } }