コード例 #1
0
        public IActionResult Login(IndexViewModels userSubmission)
        {
            if (ModelState.IsValid)
            {
                // If inital ModelState is valid, query for a user with provided email
                var userInDb = dbContext.Users.FirstOrDefault(u => u.Email == userSubmission.login.LogEmail);
                // If no user exists with provided email
                if (userInDb == null)
                {
                    // Add an error to ModelState and return to View!
                    ViewBag.LogEmail = "Invalid Email/Password";
                    return(View("Index"));
                }

                // Initialize hasher object
                var hasher = new PasswordHasher <User>();

                // verify provided password against hash stored in db
                var result = hasher.VerifyHashedPassword(userSubmission.newUser, userInDb.Password, userSubmission.login.LogPassword);

                // result can be compared to 0 for failure
                if (result == 0)
                {
                    // handle failure (this should be similar to how "existing email" is handled)
                    ViewBag.LogEmail = "Invalid Email/Password";
                    return(View("Index"));
                }

                HttpContext.Session.SetInt32("User", userInDb.UserId);
                Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine(HttpContext.Session.GetString("User"));
                return(RedirectToAction("Success"));
            }
            return(View("Index"));
        }
コード例 #2
0
        // GET: Articulo
        public ActionResult Index(string idTipoArticulo = "")
        {
            if (Session["Session_Usuario_Id"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            var _model = new IndexViewModels();

            if (idTipoArticulo != "")
            {
                _model.TipoDeArticulo = _blogArticuloServicio.ObtenerTipoArticuloPorId(idTipoArticulo, ref mensaje);
                _model.Articulos      = _blogArticuloServicio.ObtenerArticuloPorTipo(idTipoArticulo, ref mensaje).ToList();
            }
            else
            {
                _model.TipoDeArticulo = new TipoArticulo()
                {
                    Id     = 0,
                    Nombre = "TODAS"
                };
                _model.Articulos = _blogArticuloServicio.ObtenerArticulosActivos().ToList();
            }
            return(View(_model));
        }
コード例 #3
0
        public ActionResult Index()
        {
            var model = new IndexViewModels
            {
                Languages =
                {
                    CurrentCount = langService.GetByActiveProject(UserActiveProject).Count(),
                    ActiveCount  = langService.GetActiveByActiveProject(UserActiveProject).Count()
                },
                Contexts =
                {
                    CurrentCount =
                        phrsContService.GetAllByIdProject(UserActiveProject, User.Identity.GetUserId()).Count(),
                    Translated   =
                        phrsContService.GetTranslatedByIdProject(UserActiveProject, User.Identity.GetUserId()).Count()
                },
                Projects           = { ProjectCount = projectServices.GetForUser(User.Identity.GetUserId()).Count() },
                SystemStabilityBox = GetSystemStabilityLoggsViewModel(),
                BearerToken        = tokenContainer.ApiToken?.ToString()
            };



            SetViewBagsAndHeaders(Request.IsAjaxRequest(), "Dashboard", "Hello! This is your administration panel.");
            if (Request.IsAjaxRequest())
            {
                return(PartialView(model));
            }

            return(View(model));
        }
コード例 #4
0
        private void TotalizatorDestroy(IndexViewModels totalizator)
        {
            ManagementNomenclaturesSoapClient client = new ManagementNomenclaturesSoapClient();

            client.Endpoint.EndpointBehaviors.Add(new MessageBehavior("_system", "SYS"));
            client.DeleteRecordTag(totalizator.TotalizerTag, Convert.ToInt32(totalizator.ControlPointID), Convert.ToInt32(totalizator.FlowDirection),
                                   Convert.ToInt32(totalizator.ControlerCode), Convert.ToInt32(totalizator.PositionNumber));
        }
コード例 #5
0
        public ActionResult Delete([DataSourceRequest] DataSourceRequest request, IndexViewModels totalizator)
        {
            if (totalizator != null)
            {
                TotalizatorDestroy(totalizator);
            }

            return(Json(new[] { totalizator }.ToDataSourceResult(request, ModelState)));
        }
コード例 #6
0
        public ActionResult Index()
        {
            IndexViewModels models = new IndexViewModels();

            models.AccomodationTypes    = AccomodationTypesServices.Instance.GetAllAccomodationTypes();
            models.AccomodationPackages = AccomodationPackagesServices.Instance.GetAllAccomodationPackages();
            models.Amenities            = AmenitiesServices.Instance.SearchAllAmenities("");
            return(View(models));
        }
コード例 #7
0
        public IActionResult Index()
        {
            //获取站内新闻
            var selfNews = _context.Blog
                           .Where(m => m.Catalog.Value.Equals("articleSelfNews"))
                           .Where(m => m.Status.Equals(StatusType.Publish))
                           .OrderByDescending(m => m.UpdateTime)
                           .Take(4)
                           .ToList();

            var news = _context.BingNews
                       .Where(m => m.Tags.Equals("微软"))
                       .OrderByDescending(m => m.CreatedTime)
                       .Take(8)
                       .ToList();

            var msBlogs = _context.RssNews
                          .OrderByDescending(m => m.LastUpdateTime)
                          .Take(8)
                          .ToList();

            var c9Videos = _context.C9videos
                           .OrderByDescending(m => m.UpdatedTime)
                           .Take(3)
                           .ToList();

            var Videos = _context.Video
                         .OrderByDescending(m => m.CreatedTime)
                         .Take(3)
                         .ToList();

            var downloads = _context.Resource
                            .Where(m => m.Catalog.Type.Equals("下载"))
                            .Where(m => m.IsRecommend == true)
                            .OrderByDescending(m => m.UpdatedTime)
                            .ToList();

            var documents = _context.Resource
                            .Where(m => m.Catalog.Type.Equals("文档"))
                            .Where(m => m.IsRecommend == true)
                            .OrderByDescending(m => m.UpdatedTime)
                            .ToList();

            var data = new IndexViewModels()
            {
                BingNews  = news,
                MsBlogs   = msBlogs,
                Downloads = downloads,
                Documents = documents,
                C9Videos  = c9Videos,
                Videos    = Videos,
                SelfNews  = selfNews
            };

            return(View(data));
        }
コード例 #8
0
        // GET: Home
        public ActionResult Index()
        {
            //var li = db.Kisiler.ToList();

            IndexViewModels model = new IndexViewModels();

            model.Kisiler  = db.Kisiler.ToList();
            model.Adresler = db.Adresler.ToList();

            return(View(model));
        }
コード例 #9
0
        public IActionResult Index(string NameS, int?GroupId, string Name, string Description, int page = 1, SortState sortOrder = SortState.GroupIdAcs)
        {
            int pageSize = 10;

            IQueryable <Artists> source = _context.Artists.Include(a => a.Group);

            ViewData["NameSSort"]   = sortOrder == SortState.NameSAcs ? SortState.NameSDesc : SortState.NameSAcs;
            ViewData["GroupIdSort"] = sortOrder == SortState.GroupIdAcs ? SortState.GroupIdDesc : SortState.GroupIdAcs;


            if (NameS != null)
            {
                source = source.Where(x => x.NameS == NameS);
            }
            if (GroupId != null)
            {
                source = source.Where(x => x.GroupId == GroupId);
            }


            switch (sortOrder)
            {
            case SortState.NameSAcs:
                source = source.OrderBy(x => x.NameS);
                break;

            case SortState.NameSDesc:
                source = source.OrderByDescending(x => x.NameS);
                break;

            case SortState.GroupIdAcs:
                source = source.OrderBy(x => x.GroupId);
                break;

            case SortState.GroupIdDesc:
                source = source.OrderByDescending(x => x.GroupId);
                break;
            }


            var           count    = source.Count();
            var           items    = source.Skip((page - 1) * pageSize).Take(pageSize);
            PageViewModel pageView = new PageViewModel(count, page, pageSize);

            IndexViewModels ivm = new IndexViewModels
            {
                PageViewModel = pageView,
                FilterView    = new FilterView(NameS, GroupId, Name, Description),
                Artists       = items
            };

            return(View(ivm));
        }
コード例 #10
0
        public IActionResult Index(string NameS, int?GroupId, string Name, string Description, int page = 1, SortState sortOrder = SortState.DescriptionAcs)
        {
            int pageSize = 5;

            IQueryable <Groups> source = _context.Groups;

            ViewData["NameSort"]        = sortOrder == SortState.NameAcs ? SortState.NameDesc : SortState.NameAcs;
            ViewData["DescriptionSort"] = sortOrder == SortState.DescriptionAcs ? SortState.DescriptionDesc : SortState.DescriptionAcs;


            if (Name != null)
            {
                source = source.Where(x => x.Name == Name);
            }
            if (Description != null)
            {
                source = source.Where(x => x.Description == Description);
            }


            switch (sortOrder)
            {
            case SortState.NameAcs:
                source = source.OrderBy(x => x.Name);
                break;

            case SortState.NameDesc:
                source = source.OrderByDescending(x => x.Name);
                break;

            case SortState.DescriptionAcs:
                source = source.OrderBy(x => x.Description);
                break;

            case SortState.DescriptionDesc:
                source = source.OrderByDescending(x => x.Description);
                break;
            }


            var           count    = source.Count();
            var           items    = source.Skip((page - 1) * pageSize).Take(pageSize);
            PageViewModel pageView = new PageViewModel(count, page, pageSize);

            IndexViewModels ivm = new IndexViewModels
            {
                PageViewModel = pageView,
                FilterView    = new FilterView(NameS, GroupId, Name, Description),
                Groups        = items
            };

            return(View(ivm));
        }
コード例 #11
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, IndexViewModels totalizator)
        {
            var result = VerifyProductCodeBool(totalizator.ProductCode);

            TempData["ResultMessage"] = new ResultOfAction()
            {
            };
            if (result && totalizator != null)
            {
                TotalizatorUpdate(totalizator);
                return(Json(new[] { totalizator }.ToDataSourceResult(request, ModelState)));
            }
            return(Json(null));
        }
コード例 #12
0
ファイル: HomeController.cs プロジェクト: cqdat/NhomXingfa
        public ActionResult Index()
        {
            IndexViewModels model = new IndexViewModels();

            model.lstHomeBanner    = db.Slides.Where(a => a.CategoryID == 0).ToList();
            model.blogGioiThieu    = db.Blogs.Where(a => a.BlogID == 3).FirstOrDefault();
            model.lstServices      = db.Blogs.Where(b => b.TypeBlog == WebConstants.BlogAboutUs_more && b.IsActive == true && b.BlogID != 3).ToList();
            model.lstProductNoibat = db.ProductGroups.Where(a => a.GroupCode == WebConstants.ProductNoiBat).Take(8).ToList();
            model.listSPMoi        = db.ProductGroups.Where(a => a.GroupCode == WebConstants.ProductMoi).Take(5).ToList();
            model.lstListProjects  = db.Products.Where(p => p.IsActive == true && p.IsProduct == false && p.ProductCode == "BST").OrderByDescending(p => p.ProductID).Take(8).ToList();
            model.lstLastNews      = db.Blogs.Where(q => q.IsActive == true && q.TypeBlog == WebConstants.BlogNews).OrderByDescending(q => q.LastModify).Take(3).ToList();
            ViewBag.Title          = "Trang Chủ";
            return(View(model));
        }
コード例 #13
0
        //
        // GET: /Manage/Index
        public async Task <ActionResult> Index(ManageMessageId?message)
        {
            ViewBag.StatusMessage =
                message == ManageMessageId.ChangePasswordSuccess ? "Your password has been changed."
                : message == ManageMessageId.SetPasswordSuccess ? "Your password has been set."
                : message == ManageMessageId.SetTwoFactorSuccess ? "Your two-factor authentication provider has been set."
                : message == ManageMessageId.Error ? "An error has occurred."
                : message == ManageMessageId.AddPhoneSuccess ? "Your phone number was added."
                : message == ManageMessageId.RemovePhoneSuccess ? "Your phone number was removed."
                : "";

            var userId = User.Identity.GetUserId();
            var model  = new IndexViewModels
            {
                HasPassword       = HasPassword(),
                PhoneNumber       = await UserManager.GetPhoneNumberAsync(userId),
                TwoFactor         = await UserManager.GetTwoFactorEnabledAsync(userId),
                Logins            = await UserManager.GetLoginsAsync(userId),
                BrowserRemembered = await AuthenticationManager.TwoFactorBrowserRememberedAsync(userId)
            };

            return(View(model));
        }
コード例 #14
0
        public ActionResult Index(int?edad, int pagina = 1)

        {
            var cantidadRegistrosPorPagina = 2; //parametro

            using (var db = new ApplicationDbContext())
            {
                Func <Persona, bool> predicado = x => !edad.HasValue || edad.Value == x.Edad;
                var personas = db.Personas.OrderBy(x => x.Id)
                               .Skip((pagina - 1) * cantidadRegistrosPorPagina)
                               .Take(cantidadRegistrosPorPagina).ToList();
                var totalDeRegistros = db.Personas.Count();

                var modelo = new IndexViewModels();
                modelo.Personas                   = personas;
                modelo.PaginaActual               = pagina;
                modelo.TotalDeRegistros           = totalDeRegistros;
                modelo.RegistrosPorPagina         = cantidadRegistrosPorPagina;
                modelo.ValoresQueryString         = new RouteValueDictionary();
                modelo.ValoresQueryString["edad"] = edad;
                return(View(modelo));
            }
        }
コード例 #15
0
        public ActionResult Index(int?ced, int pagina = 1)
        {
            var cantidadRegistrosPorPagina = 20; // parámetro

            using (var bd = new SIMAMUSEntities())
            {
                Func <RegistroResultados, bool> predicado = x => !ced.HasValue || ced.Value == x.CedulaPaciente;

                var personas = bd.RegistroResultados.Where(x => x.CedulaPaciente == ced || ced == null).OrderByDescending(x => x.IdRegistro)
                               .Skip((pagina - 1) * cantidadRegistrosPorPagina)
                               .Take(cantidadRegistrosPorPagina).ToList();
                var totalDeRegistros = db.RegistroResultados.Where(x => x.CedulaPaciente == ced || ced == null).Count();

                var modelo = new IndexViewModels();
                modelo.Registros                 = personas;
                modelo.PaginaActual              = pagina;
                modelo.TotalDeRegistros          = totalDeRegistros;
                modelo.RegistrosPorPagina        = cantidadRegistrosPorPagina;
                modelo.ValoresQueryString        = new RouteValueDictionary();
                modelo.ValoresQueryString["ced"] = ced;

                return(View(modelo));
            }
        }
コード例 #16
0
        public IActionResult Register(IndexViewModels modelData)
        {
            if (ModelState.IsValid)
            {
                PasswordHasher <User> Hasher = new PasswordHasher <User>();
                modelData.newUser.Password = Hasher.HashPassword(modelData.newUser, modelData.newUser.Password);
                // If a User exists with provided email
                if (dbContext.Users.Any(u => u.Email == modelData.newUser.Email))
                {
                    // Manually add a ModelState error to the Email field, with provided
                    // error message
                    ViewBag.Email = "Email already in use";


                    return(View("Index"));
                }
                dbContext.Add(modelData.newUser);
                // OR dbContext.Users.Add(newUser);
                dbContext.SaveChanges();
            }

            // Check initial ModelState
            return(View("Index"));
        }