public async Task <IActionResult> AddMembership(NewMembershipModel m, IFormCollection image) { string storePath = "/images/membership/"; var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot", "images", "membership", image.Files[0].FileName); using (var stream = new FileStream(path, FileMode.Create)) { await image.Files[0].CopyToAsync(stream); } var membership = new Membership { MembershipName = m.MembershipName, MembershipDescription = m.MembershipDescription, MembershipImageUrl = storePath + m.Image.FileName, MembershipPrice = m.MembershipPrice }; await _membershipService.AddMembership(membership); return(RedirectToAction("Index", "Membership")); }
public IActionResult Create() { var m = new NewMembershipModel(); return(View(m)); }