public BooleanInformationModel StoreResourceAllocationValues(DoubleIDModel d) { B = new BooleanInformationModel(); int Rcount = dbcontext.ResourceAllocations.Where(c => c.ResourceID == d.ID2).Count(); var Rresult = dbcontext.Resources.Any(c => c.ResourceID == d.ID2 && c.Threshold > Rcount); if (Rresult == true) { ResourceAllocation value = new ResourceAllocation() { ProjectID = d.ID1, ResourceID = d.ID2 }; dbcontext.ResourceAllocations.Add(value); dbcontext.SaveChanges(); int RAcount = dbcontext.ResourceAllocations.Where(c => c.ProjectID == d.ID1).Count(); Project Pr = dbcontext.Projects.Single(proj => proj.ProjectID == d.ID1); Pr.NoOfResources = RAcount; dbcontext.SaveChanges(); B.TrueOrFalse = true; } else { B.TrueOrFalse = false; } return(B); }
private async void AddResAllocationBtn_ClickAsync(object sender, EventArgs e) { if (Validation_Check_For_Resource_Allocation() == true) { bool success = Int32.TryParse(SelectProCmbBox.SelectedValue.ToString(), out int id1); bool success1 = Int32.TryParse(SelectResCmbBox.SelectedValue.ToString(), out int id2); if (success && success1) { DoubleIDModel d = new DoubleIDModel { ID1 = id1, ID2 = id2 }; BooleanInformationModel B = await RAB.StoreResourceAllocationAsync(d); if (B.TrueOrFalse) { MessageBox.Show("ResourceAllocation is done"); } else { MessageBox.Show("ResourceAllocation can't be done"); } } SelectProCmbBox_SelectedIndexChangedAsync(SelectProCmbBox.SelectedValue, null); var projectNameOnly2 = await RAB.ShowProjectNameOnlyAsync(); this.ChoosePrjNameCmbBox.SelectedIndexChanged -= new System.EventHandler(this.ChoosePrjNameCmbBox_SelectedIndexChangedAsync); ChoosePrjNameCmbBox.DataSource = projectNameOnly2; ChoosePrjNameCmbBox.DisplayMember = "ProjectName"; ChoosePrjNameCmbBox.ValueMember = "ProjectID"; ChoosePrjNameCmbBox.SelectedIndex = -1; this.ChoosePrjNameCmbBox.SelectedIndexChanged += new System.EventHandler(this.ChoosePrjNameCmbBox_SelectedIndexChangedAsync); var project = await PB.ShowProjectDataAsync(); ProjectDataGrid.DataSource = project; var projectNameOnly3 = await RAB.ShowResourceNameOnlyAsync(); this.ChooseResNameCmbBox.SelectedIndexChanged -= new System.EventHandler(this.ChooseResNameCmbBox_SelectedIndexChangedAsync); ChooseResNameCmbBox.DataSource = projectNameOnly3; ChooseResNameCmbBox.DisplayMember = "Name"; ChooseResNameCmbBox.ValueMember = "ResourceID"; ChooseResNameCmbBox.SelectedIndex = -1; this.ChooseResNameCmbBox.SelectedIndexChanged += new System.EventHandler(this.ChooseResNameCmbBox_SelectedIndexChangedAsync); this.ResourceDataGrid.DataSource = null; //ResourceDataGrid.Rows.Clear(); ResourceDataGrid.Refresh(); ProjectDataGrid.DataSource = null; ProjectDataGrid.Rows.Clear(); ProjectDataGrid.Refresh(); } }
public BooleanInformationModel StoreResourceAllocation(DoubleIDModel d) { return(_service.StoreResourceAllocationValues(d)); }
public async Task <BooleanInformationModel> StoreResourceAllocationAsync(DoubleIDModel d) { return(await web.PostAsync <BooleanInformationModel, DoubleIDModel>("resourceallocation//storeresourceallocation", d)); }