Example #1
0
        public ActionResult Products()
        {
            IAdminRepositoryService _adminRepositoryService = new AdminRepositoryService();
            List <Product>          Products = _adminRepositoryService.GetAllProducts();

            return(View(Products));
        }
Example #2
0
 public GitStorage(GitStorageSettings settings, GitHubService gitHubService, AdminRepositoryService adminRepositoryService, UserRepositoryService userRepositoryService, SystemService system)
 {
     System = system;
     if (settings.Local)
     {
         Root = settings.Root;
     }
     this.gitHubService          = gitHubService;
     this.userRepositoryService  = userRepositoryService;
     this.adminRepositoryService = adminRepositoryService;
 }
Example #3
0
        public ActionResult UserLogin(UserLogin login)
        {
            IAdminRepositoryService _adminRepositoryService = new AdminRepositoryService();
            UsersInfo info = _adminRepositoryService.UserAuthentication(login);

            if (info != null)
            {
                UsersRole role = _adminRepositoryService.GetRoleByRoleId(Convert.ToInt32(info.RoleId));
                if (role.RoleName.Equals("SuperUser") || role.RoleName.Equals("Admin"))
                {
                    Session["RoleName"] = role.RoleName;
                    Session["RoleId"]   = info.UserId;

                    CustomPrincipalSerializeModel serializeModel = new CustomPrincipalSerializeModel();
                    serializeModel.UserId   = info.UserId;
                    serializeModel.UserName = info.UserName;
                    serializeModel.roles    = new string[] { role.RoleName };

                    string userData = JsonConvert.SerializeObject(serializeModel);
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                        1,
                        info.UserName,
                        DateTime.Now,
                        DateTime.Now.AddMinutes(5),
                        false,
                        userData);

                    string     encTicket = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie faCookie  = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                    Response.Cookies.Add(faCookie);

                    return(RedirectToAction("Index", "Admin"));
                }
            }
            return(View());
        }