Beispiel #1
0
        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));
        }