public ActionResult Edit(Customer model) { var f = Request.Files["upPhoto"]; if (f != null && f.ContentLength > 0) { var ext = f.FileName.Substring(f.FileName.LastIndexOf(".")); var path = Server.MapPath("~/images/customers/" + model.Id + ext); f.SaveAs(path); model.Photo = model.Id + ext; } db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return View(model); }
public async Task<ActionResult> Register(Customer model) { if (!XCaptcha.IsValid) { ModelState.AddModelError("", "Invalid security code !"); return View(model); } if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.Id }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { db.Customers.Add(model); db.SaveChanges(); await SignInAsync(user, isPersistent: false); return RedirectToAction("Index", "Home"); } else { AddErrors(result); } } // If we got this far, something failed, redisplay form return View(model); }