Example #1
0
        internal static GetWorkingDaysResponse getWorkingDays(GetWorkingDaysRequest getLeaveDaysRequest, HttpRequestMessage request)
        {
            GetWorkingDaysResponse response = new GetWorkingDaysResponse();

            try
            {
                LeaveDAL leaveDAL         = new LeaveDAL();
                var      sessionDetails   = AuthDAL.getSession(getLeaveDaysRequest.Fb_id);
                var      leaveDaysDataSet = leaveDAL.Employee_GetLeaveDay(
                    getLeaveDaysRequest.From_Date,
                    getLeaveDaysRequest.To_Date,
                    getLeaveDaysRequest.From_Time,
                    getLeaveDaysRequest.To_Time,
                    sessionDetails["UserGUID"] as string,
                    sessionDetails["CompanyGUID"] as string
                    );
                // ToDo: Calculate the current balance and check if the required leaves is within the range
                //leaveDAL.Get_CurrentBalance(
                //    sessionDetails["UserGUID"] as string,
                //    getLeaveDaysRequest.LeaveTypeId,
                //    new DateTime().Year,
                //    );
                response.Success = true;
                response.Days    = leaveDaysDataSet.Tables[0].Rows[0]["LeaveDays"] as int?;
                return(response);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Error   = new Error
                {
                    Id      = ErrorCode.INTERNAL_ERROR,
                    Message = ex.Message
                };
                throw new HttpResponseException(request.CreateResponse(HttpStatusCode.InternalServerError, response));
            }
        }