예제 #1
0
        public async Task <MonthAndYearModel> GetYearAndMonths()
        {
            var response = new MonthAndYearModel();

            using (var ctx = new DbEntities())
            {
                var autoMapperConfig = new AutoMapperConfiguration().Configure();
                var iMapper          = autoMapperConfig.CreateMapper();

                response.Months = iMapper.Map <List <Months>, List <MonthModel> >(await ctx.Months.ToListAsync());
                response.Years  = iMapper.Map <List <Years>, List <YearModel> >(await ctx.Years.ToListAsync());
            }
            return(response);
        }
        public async Task <IHttpActionResult> GetYearAndMonths()
        {
            var response = new MonthAndYearModel();

            try
            {
                response = await new WebBL().GetYearAndMonths();
            }
            catch (Exception ex)
            {
                LogManager.Logger.WriteException("WebController", "GetYearAndMonths", ex.Message, ex);
            }
            return(Ok(response));
        }