public ActionResult Index(string id) { var coach = repository.GetCoachById(id); CoachViewModel vm = new CoachViewModel(); vm.ID = id; vm.FirstName = coach.FirstName; vm.SecondName = coach.SecondName; vm.TemplateId = coach.TemplateID; vm.Email = coach.Email; vm.Phone = coach.PhoneNumber; vm.Image1Name = coach.ProfileImage; // FirstName + coach.SecondName + ".jpg"; vm.Image1Path= Server.MapPath("~/content/images/uploads/"); vm.Image1Path = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/content/images/uploads/" + coach.ProfileImage; if(coach.Subscriber == true) { vm.Subscriber = true; } else { vm.Subscriber = false; } List<SelectListItem> items = new List<SelectListItem>(); items.Add(new SelectListItem { Text = "Select TEmplate", Value = "0", Selected = true }); items.Add(new SelectListItem { Text = "Red", Value = "1" }); items.Add(new SelectListItem { Text = "Blue", Value = "2" }); ViewData["TemplateType"] = items; Session["vm"] = vm; return View(vm); }
public ActionResult BSGElite(string firstname , string secondname) { var coach = repository.GetCoach(firstname, secondname); CoachViewModel vm = new CoachViewModel(); vm.ID = coach.Id; vm.FirstName = coach.FirstName; vm.SecondName = coach.SecondName; vm.TemplateId = coach.TemplateID; vm.Email = coach.Email; vm.Phone = coach.PhoneNumber; vm.Image1Name = coach.ProfileImage; // FirstName + coach.SecondName + ".jpg"; vm.Image1Path = Server.MapPath("~/content/images/uploads/"); vm.Image1Path = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/content/images/uploads/" + coach.ProfileImage; return View(vm); }
public ActionResult Index(CoachViewModel vm, HttpPostedFileBase Image1) { //Session["vm"] = vm; if (Image1 != null && Image1.ContentLength > 0) { //var fileName = Path.GetFileName(Image1.FileName); var path = Server.MapPath("~/content/images/uploads"); //System.IO.File.Delete(path + "/Coach.jpg"); if (System.IO.File.Exists(path + "/" + vm.FirstName + vm.SecondName + ".jpg")) { System.IO.File.Delete(path + "/" + vm.FirstName + vm.SecondName + ".jpg"); } /* FileInfo temp = new FileInfo(path + "/Coach.jpg"); if (temp.Exists) temp.Delete(); */ Image1.SaveAs(path + "/" + vm.FirstName + vm.SecondName + ".jpg"); vm.Image1Name = vm.FirstName + vm.SecondName + ".jpg"; } Coach c = new Coach() { Id=vm.ID, FirstName = vm.FirstName, SecondName=vm.SecondName, Email=vm.Email, PhoneNumber = vm.Phone, TemplateID = vm.TemplateId, ProfileImage= vm.FirstName + vm.SecondName + ".jpg" }; vm.Image1Name = vm.FirstName + vm.SecondName + ".jpg"; //vm.Image1Path = Server.MapPath("~/content/images/uploads") + "/" + vm.FirstName + vm.SecondName + ".jpg"; vm.Image1Path = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath + "/content/images/uploads/" + vm.Image1Name; repository.Save(c); return View(vm); }