コード例 #1
0
        public ActionResult <Api <List <SalaryHistoryEntity> > > GetSalaryHistory(
            [FromQuery(Name = "page"), DefaultValue(1), Required] int page, //
            [FromQuery(Name = "page_limit"), DefaultValue(10)] int limit,   //
            [FromQuery(Name = "month"), DefaultValue(1)] int month,         //
            [FromQuery(Name = "year"), DefaultValue(1999)] int year         //
            )
        {
            Date date = new Date()
            {
                month = month, year = year
            };
            int totalItems = _salaryService.CountAllSalaryHistoriesByDate(date);

            int totalPages = (int)Math.Ceiling((double)totalItems / limit);

            List <SalaryHistoryDTO> dtos = _salaryService.FindSalaryHistoriesByDate(page, limit, date);

            Api <List <SalaryHistoryDTO> > result = new Api <List <SalaryHistoryDTO> >((int)HttpStatusCode.OK, dtos, "Success", new Paging(page, limit, totalPages, totalItems));

            return(Ok(result));
        }