public static Expert Map(List <Object> row) { var i = new Expert(); i.id = Int32.Parse(row[0].ToString()); i.name = row[1].ToString(); return(i); }
private void issuesLB_SelectedIndexChanged(object sender, EventArgs e) { if (issuesLB.SelectedItem is Issue) { eventsLB.Items.Clear(); db.Connect(); var obj = db.GetRows("event", "*", "issue_id=" + (issuesLB.SelectedItem as Issue).id); if (obj.Count != 0) { events.Clear(); foreach (var row in obj) { events.Add(EventMapper.Map(row)); } double issueCost = 0; foreach (var ev in events) { issueCost += GetTotalCost(ev.id); } issueCostLbl.Text = issueCost.ToString(); // Get list of user ids var userIds = (from ev in events select Int32.Parse(ev.userId.ToString())).ToArray(); // Get list of expert ids from users List <int> expertIds = new List <int>(); foreach (var uid in userIds) { expertIds.Add(Int32.Parse(db.GetValue("user", "id_of_expert", "id_of_user="******"expert", "distinct id_of_expert, expert_name", "id_of_expert in (" + String.Join(",", expertIds) + ")"); for (int i = 0; i < userIds.Length; i++) { expertOfUser[userIds[i]] = expertIds[i]; } var experts = new List <Expert>(); var emptyExpert = new Expert(); emptyExpert.id = -1; emptyExpert.name = "Усі"; experts.Add(emptyExpert); expertsLB.Items.Clear(); foreach (var row in obj) { experts.Add(ExpertMapper.Map(row)); } expertsLB.Items.AddRange(experts.ToArray()); } db.Disconnect(); } }