コード例 #1
0
        public async Task <EducationResponseModel> GetEducationByIdAsync(Guid Id)
        {
            var education = await _dbContext.Education.Where(x => !x.IsDeleted && x.Id == Id).Include(x => x.Category).Include(x => x.EducationContentList).FirstOrDefaultAsync();

            var resModel = new EducationResponseModel();

            if (education != null)
            {
                foreach (var item in education.EducationContentList.Where(x => !x.IsDeleted).ToList())
                {
                    var md = item.Adapt <EducationContentResponseModel>();
                    md.EducationContenTypeName = item.EducationContentType.Description;
                    resModel.EducationContentList.Add(md);
                }

                resModel.CategoryName = education.Category?.Description;
                resModel.Cost         = education.Cost;
                resModel.Time         = education.Time;
                resModel.Quota        = education.Quota;
                resModel.Id           = education.Id;
                resModel.Name         = education.Name;
                resModel.TotalCost    = education.TotalCost;
            }

            return(resModel);
        }
コード例 #2
0
        public static EducationResponseModel ToModel(this Education education, IMediaService mediaService)
        {
            var model = new EducationResponseModel()
            {
                Name          = education.Name,
                Description   = education.Description,
                FromDate      = education.FromDate,
                ToDate        = education.ToDate,
                EducationType = education.EducationType,
                School        = education.School?.ToModel(mediaService)
            };

            return(model);
        }