Esempio n. 1
0
        public IHttpActionResult GetUsers([FromUri] PagingParameterModel Paging)
        {
            if (Paging.PageNumber <= 0)
            {
                return(BadRequest());
            }
            else
            {
                var Users = CustomerContext.Users.Where(u => u.IsDeleted == false)
                            .OrderBy(u => u.UserName)
                            .AsQueryable()
                            .Skip((Paging.PageNumber - 1) * Paging.PageSize)
                            .Take(Paging.PageSize).ToList();

                List <ApplicationUser>     AppUsers = Users.ToList();
                List <DisplayBindingModel> Models   = new List <DisplayBindingModel>();

                foreach (ApplicationUser User in AppUsers)
                {
                    DisplayBindingModel Model = new DisplayBindingModel();


                    Model.Id          = User.Id;
                    Model.NameOfUser  = User.NameOfUser;
                    Model.UserName    = User.UserName;
                    Model.Surname     = User.Surname;
                    Model.DateofBirth = User.DateofBirth;
                    Model.Email       = User.Email;

                    Models.Add(Model);
                }

                return(Ok(Models));
            }
        }
Esempio n. 2
0
        public IHttpActionResult GetUser(string Id)
        {
            var User = CustomerContext.Users.SingleOrDefault(u => u.Id == Id);

            if (User == null || User.IsDeleted == true)
            {
                return(NotFound());
            }
            else
            {
                DisplayBindingModel Model = new DisplayBindingModel();
                Model.Id          = User.Id;
                Model.NameOfUser  = User.NameOfUser;
                Model.UserName    = User.UserName;
                Model.Surname     = User.Surname;
                Model.DateofBirth = User.DateofBirth;
                Model.Email       = User.Email;

                return(Ok(Model));
            }
        }