public async Task <IActionResult> AddSession(AddSessionModel model, IFormCollection image) { string storePath = "/images/session/"; var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", "images", "session", image.Files[0].FileName); using (var stream = new FileStream(path, FileMode.Create)) { await image.Files[0].CopyToAsync(stream); } var session = new Session { SessionName = model.Name, SessionDescription = model.Description, SessionImageUrl = storePath + model.Image.FileName, ClassPriceNoMember = model.ClassPriceNoMember, ClassPriceMember = model.ClassPriceMember, }; await _sessionService.Create(session); return(RedirectToAction("Index", "Session")); }