public List <OffRequestsData> SelectApprovalData(string employeeId) { var dataList = new List <OffRequestsData>(); using var dataTable = dbHelper.GetDataTable($"select * from OffRequests where ApprovalId = '{employeeId}' order by UserId, ScheduledDate DESC"); foreach (var row in dataTable.Rows.Cast <DataRow>()) { OffRequestsData data = new OffRequestsData(); data.PrimaryId = int.Parse(row["PrimaryId"].ToString()); data.UserId = row["UserId"].ToString(); data.RequestTypeId = row["RequestTypeId"].ToString(); data.ScheduledDate = DateTime.Parse(row["ScheduledDate"].ToString()); data.Reason = row["Reason"].ToString(); data.ApprovalId = row["ApprovalId"].ToString(); data.ApprovalFlg = int.Parse(row["ApprovalFlg"].ToString()); if (!String.IsNullOrEmpty(row["ApprovalDate"].ToString())) { data.ApprovalDate = DateTime.Parse(row["ApprovalDate"].ToString()); } dataList.Add(data); } return(dataList); }
public int InsertData(OffRequestsData data) { var ret = -1; var query = $"insert into OffRequests (UserId, RequestTypeId, ScheduledDate, Reason, ApprovalId) " + $"values ('{data.UserId}', '{data.RequestTypeId}', '{data.ScheduledDate}', '{data.Reason}', '{data.ApprovalId}')"; ret = dbHelper.ExecuteQuery(query); return(ret); }
private int InsertOffRequests(OffRequestsData data) { var ret = -1; try { OffRequestsHelper dbHelper = new OffRequestsHelper(_appSettings.Secrets.DbConnectionString); ret = dbHelper.InsertData(data); _logger.LogDebug("Result count: {0}", ret); } catch (Exception ex) { _logger.LogError("Error InsertOffRequests: {0}", ex.Message); } return(ret); }
private void sendOffRequest(string leadUserId) { try { var ScheduledDays = CalcScheduledDays(); for (int i = 0; i < ScheduledDays; i++) { OffRequestsData data = new OffRequestsData(); data.UserId = HttpContext.Session.GetString(Constants.Session.EmployeeId); data.RequestTypeId = Request.Form["RequestTypes"]; data.ScheduledDate = DateTime.Parse(Request.Form["FromDate"]).AddDays(i); data.Reason = Request.Form["Reason"]; data.ApprovalId = leadUserId; InsertOffRequests(data); } } catch (Exception ex) { _logger.LogError("Error sendOffRequest: {0}", ex.Message); } }