Beispiel #1
0
        public ActionResult Secret()
        {
            var db = new AuthDb(Properties.Settings.Default.ConStr);
            var vm = new SecretViewModel
            {
                User = db.GetByEmail(User.Identity.Name)
            };

            return(View(vm));
        }
Beispiel #2
0
        public ActionResult Upload(Image image, HttpPostedFileBase imageFile)
        {
            var fileName = $"{Guid.NewGuid()}{Path.GetExtension(imageFile.FileName)}";

            imageFile.SaveAs(Path.Combine(Server.MapPath("/UploadedImages"), fileName));
            image.FileName = fileName;
            var authDb = new AuthDb(Properties.Settings.Default.ConStr);
            var user   = authDb.GetByEmail(User.Identity.Name);

            image.UserId = user.Id;
            var db = new ImageDb(Properties.Settings.Default.ConStr);

            db.Add(image);
            return(View(image));
        }
        public ActionResult Index()
        {
            var vm = new HomePageViewModel
            {
                IsAuthenticated = User.Identity.IsAuthenticated
            };

            if (User.Identity.IsAuthenticated)
            {
                var db   = new AuthDb(Properties.Settings.Default.ConStr);
                var user = db.GetByEmail(User.Identity.Name);
                vm.Name = user.Name;
            }

            return(View(vm));
        }