public async Task <IActionResult> AddEducationContent(AddEducationContentRequestModel model) { if (model is null) { return(Json(new { failed = true, message = "Veri boş" })); } if (model.File != null) { Guid g = Guid.NewGuid(); var fileName = g.ToString() + model.File.FileName; var folderName = "wwwroot\\UploadFiles"; var filePath = Path.Combine(_env.ContentRootPath, folderName, fileName); using (var stream = new FileStream(filePath, FileMode.Create)) { model.File.CopyTo(stream); } model.FilePath = fileName; } model.UserId = User.Identity.GetUserId(); var educationContent = await _educationService.CreateEducationContentAsync(model); return(PartialView("~/Views/Education/_PartialEducationContentList.cshtml", educationContent)); }
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); }