public ActionResult Create(TutorLessonDTO model) { model.EkleyenId = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value) .SingleOrDefault()); model.Guid = Guid.NewGuid(); model.EklenmeZamani = DateTime.Now; model.Aktif = true; model.Silindi = false; _tutorLessonService.Create(model); return(RedirectToAction("Index")); }
public async Task <IActionResult> Create(LessonDTO model, IFormFile file) { var path = Path.Combine("Uploads", "DefaultPicture", "defaultLesson.png"); if (file != null) { var webRoot = Path.Combine("Uploads", "Documents"); path = Path.Combine(webRoot, file.FileName); using (var stream = new FileStream(path, FileMode.Create)) { await file.CopyToAsync(stream); } } model.Resim = path; model.EkleyenId = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value) .SingleOrDefault()); model.Guid = Guid.NewGuid(); model.EklenmeZamani = DateTime.Now; model.Aktif = true; model.Silindi = false; var lessonId = _lessonService.Create(model); var tutorLesson = new TutorLessonDTO() { Guid = Guid.NewGuid(), Aktif = true, EklenmeZamani = DateTime.Now, KullaniciId = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value) .SingleOrDefault()), LessonId = lessonId, Silindi = false, EkleyenId = Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name).Select(c => c.Value) .SingleOrDefault()) }; _tutorLessonService.Create(tutorLesson); var user = _kullaniciService.GetById(Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name) .Select(c => c.Value) .SingleOrDefault())); return(RedirectToAction("GetTeacher", new RouteValueDictionary(new { controller = "Account", action = "GetTeacher", guid = user.Guid }))); }