コード例 #1
0
        public async Task <List <EducationContentResponseModel> > CreateEducationContentAsync(AddEducationContentRequestModel model)
        {
            var educationContent = model.Adapt <EducationContent>();

            educationContent.RecordUserId = model.UserId.Value;

            var educationContentTypeName = model.EducationContenType.ToString();

            var educationContentType = await _dbContext.EducationContentType.Where(x => x.Name == educationContentTypeName && !x.IsDeleted).FirstOrDefaultAsync();

            if (educationContentType != null)
            {
                educationContent.EducationContentType = educationContentType;

                await _dbContext.EducationContent.AddAsync(educationContent);

                var resultValue = await _uow.CommitAsync();

                if (resultValue)
                {
                    var reqModel = new ByIdRequestModel();
                    reqModel.Id = educationContent.EducationId;

                    var resModel = await GetAllEducationContentByEducationId(reqModel);

                    return(resModel);
                }
            }



            return(null);
        }
コード例 #2
0
        public async Task <EducationResponseModel> BuyEducation(ByIdRequestModel model)
        {
            var education = await _dbContext.Education.Where(x => !x.IsDeleted && x.Id == model.Id).FirstOrDefaultAsync();

            if (education != null)
            {
                var userEducation = new UserEducation();
                userEducation.Education = education;
                userEducation.UserId    = model.UserId.Value;

                var userEducationStatus = await _dbContext.UserEducationStatus.Where(x => !x.IsDeleted && x.Name == Constants.UserEducationStatus.Request.ToString()).FirstOrDefaultAsync();

                if (userEducationStatus != null)
                {
                    userEducation.UserEducationStatus = userEducationStatus;
                    education.RecordUserId            = model.UserId.Value;

                    await _dbContext.UserEducation.AddAsync(userEducation);

                    var resultValue = await _uow.CommitAsync();

                    if (resultValue)
                    {
                        var resModel = education.Adapt <EducationResponseModel>();
                        return(resModel);
                    }
                }
            }

            return(null);
        }
コード例 #3
0
        public async Task <IActionResult> StartEducationByUserEducationId(ByIdRequestModel model)
        {
            model.UserId = User.Identity.GetUserId();

            var education = await _userEducationService.StartEducationByEducationId(model);

            return(View("EducationContent", education));
        }
コード例 #4
0
        public async Task TrainingEducation(ByIdRequestModel model)
        {
            var userEducation = await _dbContext.UserEducation.Where(x => !x.IsDeleted && x.Id == model.Id).Include
                                    (x => x.Education).FirstOrDefaultAsync();

            userEducation.IsCompleted       = false;
            userEducation.LastWathedOrderNo = null;

            await _uow.CommitAsync();
        }
コード例 #5
0
        public IActionResult EducationList()
        {
            var model = new ByIdRequestModel();

            model.Id = User.Identity.GetUserId();

            var list = _userEducationService.GetAllEducationByUserId(model);

            ViewBag.CompletedEducationList = _userEducationService.GetAllCompletedEducationByUserId(model);

            return(View(list));
        }
コード例 #6
0
        public async Task <User> DeleteUserAsync(ByIdRequestModel model)
        {
            var user = await _userRepository.GetByIdAsync(model.Id);

            if (user != null)
            {
                user.IsDeleted = true;
                _userRepository.Update(user);
            }

            return(user);
        }
コード例 #7
0
        public List <UserEducationResponseModel> GetAllCompletedEducationByUserId(ByIdRequestModel model)
        {
            var userEducationList = _dbContext.UserEducation.Where(x => !x.IsDeleted && x.UserId == model.Id && x.UserEducationStatus.Name == Constants.UserEducationStatus.Request.ToString() && x.IsCompleted).Include(x => x.Education).ThenInclude(x => x.Category).ToList();

            var resModel = new List <UserEducationResponseModel>();

            foreach (var item in userEducationList)
            {
                var md = new UserEducationResponseModel();
                md = item.Adapt <UserEducationResponseModel>();
                md.EducationResponseModel = item.Education.Adapt <EducationResponseModel>();

                resModel.Add(md);
            }

            return(resModel);
        }
コード例 #8
0
        public async Task <IActionResult> BuyEducation(ByIdRequestModel model)
        {
            if (model.Id == Guid.Empty)
            {
                return(Json(new { failed = true, message = "Null educationId." }));
            }

            model.UserId = User.Identity.GetUserId();

            var education = await _userEducationService.BuyEducation(model);

            if (education != null)
            {
                return(Json(new { failed = false, message = "Added education" }));
            }
            else
            {
                return(Json(new { failed = true, message = "An error occurred" }));
            }
        }
コード例 #9
0
        public async Task <IActionResult> DeleteUser([FromBody] ByIdRequestModel model)
        {
            if (model.Id == 0)
            {
                return(BadRequest(new { message = "Geçersiz id!" }));
            }
            var user = await _userService.DeleteUserAsync(model);

            if (user == null)
            {
                return(BadRequest(new { message = "Kullanici silinirken hata oluştu!" }));
            }

            var resModel = new ByNameResponseModel()
            {
                UserName = user.UserName
            };

            return(Ok(resModel));
        }
コード例 #10
0
        public async Task <IActionResult> ContinueEducationByUserEducationId(ByIdRequestModel model)
        {
            var education = await _userEducationService.ContinueEducationByUserEducationId(model);

            return(View("EducationContent", education));
        }
コード例 #11
0
        public async Task <IActionResult> TrainingEducation(ByIdRequestModel model)
        {
            await _userEducationService.TrainingEducation(model);

            return(RedirectToAction("EducationList"));
        }
コード例 #12
0
        public async Task <List <EducationContentResponseModel> > GetAllEducationContentByEducationId(ByIdRequestModel model)
        {
            var educationContentList = await _dbContext.EducationContent.Where(x => !x.IsDeleted && x.EducationId == model.Id).Include(x => x.EducationContentType).OrderBy(x => x.RowNumber).ToListAsync();

            var resModel = educationContentList.Select(item => item.Adapt <EducationContentResponseModel>()).ToList();

            return(resModel);
        }
コード例 #13
0
        public async Task <EducationContentResponseModel> ContinueEducationByUserEducationId(ByIdRequestModel model)
        {
            var userEducation = await _dbContext.UserEducation.Where(x => !x.IsDeleted && x.Id == model.Id).Include
                                    (x => x.Education).ThenInclude(x => x.EducationContentList).FirstOrDefaultAsync();

            if (userEducation != null)
            {
                var content = userEducation.Education.EducationContentList.Where(x => !x.IsDeleted && x.RowNumber > userEducation.LastWathedOrderNo).OrderBy(x => x.RowNumber).FirstOrDefault();

                var contentBack = userEducation.Education.EducationContentList.Where(x => !x.IsDeleted && x.RowNumber < content?.RowNumber).OrderBy(x => x.RowNumber).FirstOrDefault();

                var contentNext = userEducation.Education.EducationContentList.Where(x => !x.IsDeleted && x.RowNumber > content.RowNumber).OrderBy(x => x.RowNumber).FirstOrDefault();

                var educationContent = content.Adapt <EducationContentResponseModel>();

                if (contentNext != null)
                {
                    educationContent.IsNext = true;
                }
                if (contentBack != null)
                {
                    educationContent.IsBack = true;
                }
                educationContent.UserEducationId = userEducation.Id;

                return(educationContent);
            }



            return(null);
        }