public static ContainerBuilder AddInMemoryDataBase(this ContainerBuilder containerBuilder, ILoggerFactory loggerFactory = null)
        {
            var dbContextBuilder = new DbContextOptionsBuilder <BlitzStaticianDbContext>()
                                   .UseInMemoryDatabase("BlitzStatician");

            if (loggerFactory != null)
            {
                dbContextBuilder.UseLoggerFactory(loggerFactory);
            }

            var context = new BlitzStaticianDbContext(dbContextBuilder.Options);

#pragma warning disable CS0618
            var dummyTran           = new Mock <IDbContextTransaction>();
            var accountDataAccessor = new AccountDataAccessor(context, dummyTran.Object);
#pragma warning restore CS0618

            containerBuilder.RegisterInstance(context).As <BlitzStaticianDbContext>().ExternallyOwned();
            containerBuilder.RegisterType <BlitzStaticianDictionary>().As <IBlitzStaticianDictionary>();
            containerBuilder.RegisterInstance(accountDataAccessor).As <IAccountDataAccessor>();
            containerBuilder.RegisterType <ClanInfoDataAccessor>().As <IClanInfoDataAccessor>();
            containerBuilder.RegisterType <AchievementsDataAccessor>().As <IAchievementsDataAccessor>();
            containerBuilder.RegisterType <AccountsTankInfoDataAccessor>().As <IAccountsTankInfoDataAccessor>();
            containerBuilder.RegisterType <AccountInfoViewDataAccessor>().As <IAccountInfoViewDataAccessor>();

            return(containerBuilder);
        }
Ejemplo n.º 2
0
        public ActionResult Login(LoginFormModel loginFormModel)
        {
            RequestResult requestResult = AccountDataAccessor.GetAccount(loginFormModel);

            if (requestResult.IsSuccess)
            {
                var person = requestResult.Data as Person;

                if (Config.HaveLDAPSettings)
                {
                    return(View());
                }
                else
                {
                    if (string.Compare(person.Password, loginFormModel.Password) == 0)
                    {
                        var organizations = HttpRuntime.Cache.GetOrInsert("organizations", () => OrganizationDataAccessor.GetAllOrganizations());

                        requestResult = AccountDataAccessor.GetAccount(organizations, person);

                        if (requestResult.IsSuccess)
                        {
                            var    account   = requestResult.Data as Account;
                            var    ticket    = new FormsAuthenticationTicket(1, account.Id, DateTime.Now, DateTime.Now.AddHours(24), true, account.Id, FormsAuthentication.FormsCookiePath);
                            string encTicket = FormsAuthentication.Encrypt(ticket);
                            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

                            Session["Account"] = account;

                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            ModelState.AddModelError("LoginId", requestResult.Message);
                            return(View());
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("Password", Resources.Resource.WrongPassword);
                        return(View());
                    }
                }
            }
            else
            {
                ModelState.AddModelError("LoginId", requestResult.Message);
                return(View());
            }
        }
Ejemplo n.º 3
0
 public ActionResult ChangePassword(PasswordFormModel passwordFormModel)
 {
     return(Content(JsonConvert.SerializeObject(AccountDataAccessor.ChangePassword(passwordFormModel, Session["Account"] as Account))));
 }
Ejemplo n.º 4
0
        // GET: Shared
        public ActionResult GetPersonOptions_Multi([DefaultValue(1)] int PageIndex, [DefaultValue(10)] int PageSize, string Term, [DefaultValue(false)] bool IsInit)
        {
            var userList = HttpRuntime.Cache.GetOrInsert <List <Models.Shared.PersonModel> >("Users", () => AccountDataAccessor.GetAllPeople());

            RequestResult result = PersonDataAccessor.GetPersonOptions(userList, Term, IsInit);

            if (result.IsSuccess)
            {
                var queryResult = result.Data as List <SelectListItem>;

                var data = queryResult.Select(x => new { id = x.Value, text = x.Text, name = x.Text }).AsQueryable().OrderBy(x => x.id).ToPagedList(PageIndex, PageSize);

                return(Json(new { Success = true, Data = data, Total = data.TotalItemCount }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Success = false, Message = result.Message }, JsonRequestBehavior.AllowGet));
            }
        }