public SelectPageData GetActivePeriod() { try { var s2Param = HttpUtility.ParseQueryString(Request.RequestUri.Query); var page = s2Param["page"]; var size = s2Param["size"]; var q = s2Param["q"]; int pageIndex = page == null ? 0 : Convert.ToInt32(page) - 1; int pageSize = Convert.ToInt32(size); IList <OverTime> overTimes = OverTimeDetailBusiness.GetActivePeriod().ToList(); IQueryable <SelectItem> result = overTimes.Select(c => new SelectItem() { id = Convert.ToInt32(c.ID), text = c.Date.Year + "-" + c.Date.Month }).AsQueryable(); if (q != null) { result = result.Where(item => item.text.Contains(q.ToString())); } return(new SelectPageData { items = result.Skip(pageIndex * pageSize).Take(pageSize), total_count = overTimes.Count }); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); throw ex; } }
public bool IsAproved(DateModel model) { try { return(OverTimeDetailBusiness.IsApprovedOverTime(model.year, model.month)); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); throw ex; } }
public OverTimeProxy GetItem(decimal id) { try { var overTimeDetail = OverTimeDetailBusiness.GetByID(id); OverTimeProxy overTimeProxy = OverTimeDetailBusiness.ConvertToProxy(overTimeDetail); return(overTimeProxy); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); throw ex; } }
public HttpResponseMessage approve(DateModel model) { try { OverTimeDetailBusiness.ApproveOverTime(model.year, model.month); return(Request.CreateResponse(HttpStatusCode.OK, model)); } catch (UIValidationExceptions ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message)); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public HttpResponseMessage Edit(decimal id, OverTimeProxy viewModel) { try { OverTimeDetail model = OverTimeDetailBusiness.GetByID(id); model.MaxHoliday = viewModel.MaxHoliday; model.MaxNightly = viewModel.MaxNightly; model.MaxOverTime = viewModel.MaxOverTime; OverTimeDetailBusiness.UpdateOverTimeDetail(model); return(Request.CreateResponse(HttpStatusCode.OK, viewModel)); } catch (UIValidationExceptions ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.ExceptionList.Count > 0 ? ex.ExceptionList[0].Message : ex.Message)); } catch (Exception ex) { this.exceptionHandler.ApiHandleException("OverTimeController", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }