/// <summary> /// Get all the users /// </summary> // GET api/users public IEnumerable <UserViewModel> Get() { List <ApplicationUser> appUsers = db.Users.ToList(); List <UserViewModel> userViewModel = new List <UserViewModel>(); foreach (ApplicationUser appUser in appUsers) { var myHelper = new ControllersHelper(); userViewModel.Add(myHelper.GetUserViewModel(appUser, db, UserManager)); } return(userViewModel); }
// GET: Users public ActionResult Index() { List <ApplicationUser> appUsers = db.Users.ToList(); List <UserViewModel> model = new List <UserViewModel>(); foreach (ApplicationUser appUser in appUsers) { var myHelper = new ControllersHelper(); model.Add(myHelper.GetUserViewModel(appUser, db, UserManager)); } return(View(model)); }
public ActionResult DeleteConfirmed(string id) { ApplicationUser appUser = db.Users.Where(u => u.Id == id).FirstOrDefault(); var isPurchaseForClientExists = onlineShopDB.Purchase.Any(p => p.ClientId == appUser.Id); if (isPurchaseForClientExists) { ModelState.AddModelError("", "Error! An error has occured. May be related to a Purchase associated with this Client."); var myHelper = new ControllersHelper(); return(View(myHelper.GetUserViewModel(appUser, db, UserManager))); } db.Users.Remove(appUser); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Get an user by id /// </summary> // GET api/users/5 public IHttpActionResult Get(string id) { if (string.IsNullOrEmpty(id)) { return(NotFound()); } ApplicationUser appUser = db.Users.Where(u => u.Id == id).FirstOrDefault(); if (appUser == null) { return(NotFound()); } var myHelper = new ControllersHelper(); return(Ok(myHelper.GetUserViewModel(appUser, db, UserManager))); }
// GET: Users/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationUser appUser = db.Users.Where(u => u.Id == id).FirstOrDefault(); if (appUser == null) { return(HttpNotFound()); } var myHelper = new ControllersHelper(); return(View(myHelper.GetUserViewModel(appUser, db, UserManager))); }