public ResponseData GetUserDetails([FromBody] BestPerformer best) { List <Output> lst = new List <Output>(); ResponseData response = new ResponseData(); DataSet dstable = objReport.BestPerformer(best); if (dstable != null && dstable.Tables.Count > 0) { DataTable table; table = dstable.Tables[1]; if (table != null && table.Rows.Count > 0) { foreach (DataRow dr in table.Rows) { Output objout = new Output(); objout.accntID = Convert.ToInt32(dr["AccountId"]); objout.userName = Convert.ToString(dr["Name"]); objout.percentage = Convert.ToInt32(dr["Percentage"]); lst.Add(objout); } response.Data = lst.ToList(); } } return(response); }
public DataSet BestPerformer(BestPerformer obj) { try{ DataSet ds; using (var con = new MySqlConnection(database)) { con.Open(); MySqlCommand cmd = new MySqlCommand("usp_BestPerformer", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@in_FromDate", obj.startDate); cmd.Parameters.AddWithValue("@in_ToDate", obj.startDate); using (MySqlDataAdapter adr = new MySqlDataAdapter()) { ds = new DataSet(); adr.SelectCommand = cmd; adr.Fill(ds); // response.Data = ds; // response.Code = (int)HttpStatusCode.OK; return(ds); } } } catch (Exception ex) { throw ex; } }