Пример #1
0
        /// <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);
        }
Пример #2
0
        // 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));
        }
Пример #3
0
        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"));
        }
Пример #4
0
        /// <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)));
        }
Пример #5
0
        // 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)));
        }