示例#1
0
        // GET: Notes
        public ActionResult Sent()
        {
            var userID = db.ufn_GetUserID(HttpContext.User.Identity.Name);
            var notes  = db.Notes.Where(n => n.SenderID == userID).Include(n => n.User).Include(n => n.User1).OrderBy(n => n.CreationDate);

            return(View(notes.ToList()));
        }
示例#2
0
        public ActionResult UserProfile()
        {
            var id = db.ufn_GetUserID(User.Identity.Name);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            User user = db.Users.Find(id);

            if (user == null)
            {
                return(HttpNotFound());
            }
            RegisterViewModel pertinentUser = new RegisterViewModel()
            {
                UserID           = user.UserID,
                Username         = user.Username,
                Email            = user.Email,
                PasswordQuestion = user.PasswordQuestion,
                PasswordAnswer   = user.PasswordAnswer,
                PhoneNumber      = user.PhoneNumber,
                DateOfBirth      = (DateTime)user.DateOfBirth,
                FirstName        = user.FirstName,
                LastName         = user.LastName,
                RoleID           = user.Roles.Single().RoleID
            };

            return(View(pertinentUser));
        }
示例#3
0
        public ActionResult Index()
        {
            var          userID    = db.ufn_GetUserID(HttpContext.User.Identity.Name);
            List <Thing> thingList = db.Things.Where(x => x.Users.Any(e => e.UserID == userID)).ToList();

            //UserAccess[] userAccess = ap.GetUserAccess(userID);
            //List<Thing> thingList = new List<Thing>();
            //foreach(var thing in userAccess)
            //{
            //    thingList.Add(db.Things.Find(thing.ThingID));
            //}
            ViewBag.ClientList = new List <Client>(db.Clients);
            return(View(thingList));
        }
示例#4
0
        public ActionResult ControlThing(int id)
        {
            var userID = db.ufn_GetUserID(HttpContext.User.Identity.Name);

            if (ap.HaveAccess(userID, id))
            {
                Thing thing = db.Things.Find(id);
                return(View(thing));
            }
            else
            {
                TempData["AccessDenied"] = "You do not have permission to access this thing!";
                return(RedirectToAction("Index"));
            }
        }