public static List <EmployeeLeaveModel> ToEmployeeLeaveMapperModel(DbDataReader readers) { if (readers == null) { return(null); } var models = new List <EmployeeLeaveModel>(); while (readers.Read()) { var model = new EmployeeLeaveModel { Id = Convert.ToInt32(readers["Id"]), CompanyId = Convert.ToInt32(readers["CompanyId"]), EmployeeId = Convert.ToInt32(readers["EmployeeId"]), FromDate = Convert.ToDateTime(readers["FromDate"]), ToDate = Convert.ToDateTime(readers["ToDate"]), IsHalfDay = Convert.IsDBNull(readers["IsHalfDay"]) ? (bool?)null : Convert.ToBoolean(readers["IsHalfDay"]), LeaveTypeId = Convert.ToInt32(readers["LeaveTypeId"]), LeaveReason = Convert.IsDBNull(readers["LeaveReason"]) ? string.Empty : Convert.ToString(readers["LeaveReason"]), CreatedAt = Convert.IsDBNull(readers["CreatedAt"]) ? string.Empty : Convert.ToDateTime(readers["CreatedAt"]).ToString(), IsApproved = Convert.IsDBNull(readers["IsApproved"]) ? false : Convert.ToBoolean(readers["IsApproved"]), IsRejected = Convert.IsDBNull(readers["IsRejected"]) ?false : Convert.ToBoolean(readers["IsRejected"]), ApprovedById = Convert.IsDBNull(readers["ApprovedById"]) ? string.Empty : Convert.ToString(readers["ApprovedById"]).ToString(), ApprovedAt = Convert.IsDBNull(readers["ApprovedAt"]) ? (DateTime?)null : Convert.ToDateTime(readers["ApprovedAt"]), EmployeeName = Convert.IsDBNull(readers["EmployeeName"]) ? string.Empty : Convert.ToString(readers["EmployeeName"]), ApprovedBy = Convert.IsDBNull(readers["ApprovedBy"]) ? string.Empty : Convert.ToString(readers["ApprovedBy"]), }; models.Add(model); } return(models); }
public ResponseModel CreateEmployeeLeave(EmployeeLeaveModel model) { var errMessage = string.Empty; Database db = GetSQLDatabase(); var returnId = -1; using (DbConnection conn = db.CreateConnection()) { conn.Open(); DbTransaction trans = conn.BeginTransaction(); try { returnId = SaveEmployeeLeave(model, db, trans); trans.Commit(); } catch (Exception ex) { trans.Rollback(); errMessage = ex.Message; } } return(new ResponseModel { Success = string.IsNullOrEmpty(errMessage), Message = errMessage }); }
public IHttpActionResult CreateLeave(EmployeeLeaveModel json) { var model = new EmployeeLeaveModel { CompanyId = json.CompanyId, EmployeeId = json.EmployeeId, FromDate = Convert.ToDateTime(json.LeaveApplyFrom), ToDate = Convert.ToDateTime(json.LeaveApplyTo), IsHalfDay = json.IsHalfDay, LeaveTypeId = json.LeaveTypeId, LeaveReason = json.LeaveReason, CreatedAt = DateTime.Now.ToString(), IsApproved = false, IsRejected = false, RejectReason = json.RejectReason, ApprovedById = null, ApprovedAt = null, UserId = json.UserId }; var response = _leaveRepository.CreateEmployeeLeave(model); if (!response.Success) { return(Ok(response)); } return(Ok(new { Success = true })); }
public ReturnMessageModel EmployeeleaveStatusTsk(EmployeeLeaveModel model) { ReturnMessageModel result = new ReturnMessageModel(); ObjectParameter returnMessage = new ObjectParameter("ReturnMessage", typeof(String)); using (PayrollEntities db = new PayrollEntities()) { db.SpEmployeeleaveStatusTsk(model.Status, model.EmployeeLeaveId, model.InsertUserId, returnMessage); return(result); } }
public int SaveEmployeeLeave(EmployeeLeaveModel model, Database db, DbTransaction trans) { var errMessage = string.Empty; var queryParamList = new QueryParamList { new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@CompanyId", ParamValue = model.CompanyId, DBType = DbType.Int32 }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@userId", ParamValue = model.UserId }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@FromDate", ParamValue = model.FromDate.ToString(Constants.ServerDateTimeFormat), DBType = DbType.DateTime }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@ToDate", ParamValue = model.ToDate.ToString(Constants.ServerDateTimeFormat), DBType = DbType.DateTime }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@IsHalfDay", ParamValue = model.IsHalfDay, DBType = DbType.Boolean }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@LeaveTypeId", ParamValue = model.LeaveTypeId, DBType = DbType.Int32 }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@LeaveReason", ParamValue = model.LeaveReason }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@CreatedAt", ParamValue = Convert.ToDateTime(model.CreatedAt), DBType = DbType.DateTime }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@IsApproved", ParamValue = model.IsApproved, DBType = DbType.Boolean }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@IsRejected", ParamValue = model.IsRejected, DBType = DbType.Boolean }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@RejectReason", ParamValue = model.RejectReason }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@ApprovedById", ParamValue = model.ApprovedById }, new QueryParamObj { ParamDirection = ParameterDirection.Input, ParamName = "@ApprovedAt", ParamValue = model.ApprovedAt, DBType = DbType.DateTime }, }; const string sql = @" DECLARE @employeeId INT SELECT TOP 1 @employeeId=U.Id FROM ResourceTracker_EmployeeUser U WHERE U.UserId=@userId INSERT INTO ResourceTracker_LeaveApplication (CompanyId ,EmployeeId ,FromDate ,ToDate ,IsHalfDay,LeaveTypeId ,LeaveReason,CreatedAt,IsApproved,IsRejected,RejectReason,ApprovedById,ApprovedAt) VALUES (@CompanyId ,@employeeId ,@FromDate ,@ToDate ,@IsHalfDay,@LeaveTypeId ,@LeaveReason,@CreatedAt,@IsApproved,@IsRejected,@RejectReason,@ApprovedById,@ApprovedAt)"; return(DBExecCommandExTran(sql, queryParamList, trans, db, ref errMessage)); }
public ReturnMessageModel EmployeeLeaveAppliedIns(EmployeeLeaveModel model) { ReturnMessageModel result = new ReturnMessageModel(); ObjectParameter returnMessage = new ObjectParameter("ReturnMessage", typeof(String)); var userModel = JsonConvert.SerializeObject(model); using (PayrollEntities db = new PayrollEntities()) { db.SpEmployeeLeaveAppliedIns(userModel, returnMessage); result.ReturnMessage = returnMessage.Value.ToString(); return(result); } }
public async Task <IResultModel> Leave(EmployeeLeaveModel model) { var entity = await _repository.GetAsync(model.EmployeeId); if (entity == null) { return(ResultModel.NotExists); } if (entity.Status == EmployeeStatus.Leave) { return(ResultModel.Failed("该人员已办理过离职")); } using var uow = _dbContext.NewUnitOfWork(); var result = await _repository.UpdateLeaveStatus(model.EmployeeId, uow); if (result) { var leaveInfo = _mapper.Map <EmployeeLeaveInfoEntity>(model); leaveInfo.EmployeeId = model.EmployeeId; result = await _leaveInfoRepository.AddAsync(leaveInfo, uow); if (result) { uow.Commit(); //清除缓存 await _cacheHandler.RemoveAsync(CacheKeys.EMPLOYEE_TREE); await _cacheHandler.RemoveAsync($"{CacheKeys.EMPLOYEE_BASE_INFO}:{entity.Id}"); return(ResultModel.Success()); } } return(ResultModel.Failed()); }
public Task <IResultModel> Leave(EmployeeLeaveModel model) { return(_service.Leave(model)); }
public void EmployeeLeaveAppliedUpdateNew(EmployeeLeaveModel model) { _Le.EmployeeLeaveAppliedIns(model); }
public object EmployeeleaveStatusTsk(EmployeeLeaveModel model) { return(_ies.EmployeeleaveStatusTsk(model)); }