// CREATE: Admin/Account
        public ActionResult Create(AccountInfoVM accountInfoVM)
        {
            try
            {
                string password = CommonBox.StringSecurity.SHA256Encrypt(accountInfoVM.Password);
                var    account  = new Account()
                {
                    AccountName = accountInfoVM.AccountName, Password = password, RoleID = 1, CreatedDate = System.DateTime.Now, ModifiedDate = System.DateTime.Now, IsActive = true
                };
                db.Accounts.Add(account);
                db.SaveChanges();
                var siteOwner = new SiteOwner()
                {
                    SiteOwnerName = accountInfoVM.SiteOwnerName, SiteOwnerAddress = accountInfoVM.SiteOwnerAddress, SiteOwnerEmail = accountInfoVM.SiteOwnerEmail, SiteOwnerPhoneNumber = accountInfoVM.SiteOwnerPhoneNumber, GenderID = accountInfoVM.GenderID, AccountID = account.AccountID
                };
                db.SiteOwners.Add(siteOwner);
                db.SaveChanges();

                var siteowners = db.SiteOwners.Include(m => m.Account.Role).Include(m => m.Gender).Where(m => m.Account.IsActive).OrderByDescending(m => m.Account.ModifiedDate);
                ViewBag.GenderID = new SelectList(db.Genders, "GenderID", "GenderName");
                return(PartialView("_IndexAccountPage", siteowners.ToList()));
            }
            catch
            {
                ModelState.AddModelError("", "Abnormal protection mechanism in the system! ");
                Session[SessionBox.SITEOWNER_SESSION] = null;
                return(View("Login"));
            }
        }
        public void TestPageList()
        {
            foreach (var page in this._document.Descendants("page"))
            {
                ISite  currentSite = new SiteOwner().DefineSite(page, Motor.Instance.Configuration);
                string url         = currentSite != null ? currentSite.DefaultUrl : string.Empty;

                this._driver.Navigate().GoToUrl(url + page.Attribute("url").Value);

                foreach (var assert in page.Descendants("assert"))
                {
                    Specifics.IAssert asertItem = Specifics.AssertScheduler.Create(page, assert,
                                                                                   Motor.Instance.Configuration,
                                                                                   new SiteOwner());

                    if (asertItem != null)
                    {
                        asertItem.Valid(new Specifics.Context()
                        {
                            Driver = this._driver
                        });
                    }
                }
            }
        }
        public ActionResult Edit(AccountInfoVM accountInfoVM)
        {
            using (DbContextTransaction transaction = db.Database.BeginTransaction())
            {
                try
                {
                    var siteownerID = accountInfoVM.SiteOwnerID;
                    var accountID   = db.SiteOwners.Where(m => m.SiteOwnerID == siteownerID).Select(m => m.AccountID).SingleOrDefault();
                    var createdDate = db.SiteOwners.Where(m => m.SiteOwnerID == siteownerID).Select(m => m.Account.CreatedDate).SingleOrDefault();

                    if (accountInfoVM.Password != db.Accounts.Where(m => m.AccountID == accountID).Select(m => m.Password).FirstOrDefault())
                    {
                        accountInfoVM.Password = CommonBox.StringSecurity.SHA256Encrypt(accountInfoVM.Password);
                    }

                    var siteowner = new SiteOwner()
                    {
                        SiteOwnerID          = accountInfoVM.SiteOwnerID,
                        GenderID             = accountInfoVM.GenderID,
                        SiteOwnerAddress     = accountInfoVM.SiteOwnerAddress,
                        SiteOwnerEmail       = accountInfoVM.SiteOwnerEmail,
                        SiteOwnerName        = accountInfoVM.SiteOwnerName,
                        SiteOwnerPhoneNumber = accountInfoVM.SiteOwnerPhoneNumber,
                        AccountID            = accountID
                    };
                    db.Entry(siteowner).State = EntityState.Modified;
                    var account = new Account()
                    {
                        AccountID    = accountID,
                        AccountName  = accountInfoVM.AccountName,
                        CreatedDate  = createdDate,
                        IsActive     = true,
                        Password     = accountInfoVM.Password,
                        RoleID       = 1,
                        ModifiedDate = System.DateTime.Now
                    };
                    db.Entry(account).State = EntityState.Modified;
                    db.SaveChanges();
                    transaction.Commit();

                    var siteowners = db.SiteOwners.Include(m => m.Account.Role).Include(m => m.Gender).Where(m => m.Account.IsActive).OrderByDescending(m => m.Account.ModifiedDate);
                    ViewBag.GenderID = new SelectList(db.Genders, "genderID", "genderName");
                    return(PartialView("_IndexAccountPage", siteowners.ToList()));
                }
                catch
                {
                    transaction.Rollback();
                    ModelState.AddModelError("", "Abnormal protection mechanism in the system!");
                    Session[SessionBox.SITEOWNER_SESSION] = null;
                    return(View("Login"));
                }
            }
        }
Example #4
0
    public void Update(int type, int owner, int canTrain, int creepType)
    {
        Owner    = owner == -1 ? SiteOwner.None : owner == 0 ? SiteOwner.Friendly : SiteOwner.Enemy;
        CanTrain = canTrain == 0;

        switch (type)
        {
        case -1:
            Type = SiteType.None;
            break;

        case 0:
            Type = SiteType.Mine;
            break;

        case 1:
            Type = SiteType.Tower;
            break;

        case 2:
            Type = SiteType.Barrack;
            break;
        }

        switch (creepType)
        {
        case -1:
            CreepType = CreepType.None;
            break;

        case 0:
            CreepType = CreepType.Knight;
            Upkeep    = 80;
            break;

        case 1:
            CreepType = CreepType.Archer;
            Upkeep    = 100;
            break;

        case 2:
            CreepType = CreepType.Giant;
            Upkeep    = 140;
            break;
        }
    }
Example #5
0
        public void UpdateNotifyTest()
        {
            Contact[] Contacts = new Contact[1];
            Contacts[0] = new SiteOwner(siteName);

            foreach (Contact poc in Contacts)
            {
                try
                {
                    if (!poc.Equals(Contacts[0]))
                    {
                        Assert.Fail();
                    }
                }
                catch
                {
                    Exception SO = new Exception("Failure in SiteOwner");
                }
            }
        }
Example #6
0
        private SiteOwnerInfo GetSiteOwnerInfo(string sponsorLogin)
        {
            SiteOwner siteOwner = new SiteOwner();

            return(siteOwner.GetSiteOwnerInfoFromSponsorLogin(sponsorLogin));
        }
Example #7
0
        private SiteOwnerInfo GetSiteOwnerInfo()
        {
            SiteOwner siteOwner = new SiteOwner();

            return(siteOwner.GetSiteOwnerDataFromUrl(base.HttpContext.Request.Url));
        }
        //    = new SiteOwner
        //{
        //    OwnerLogin = new Login
        //    {
        //        UserName = Configuration.AdminUser,
        //        Password = Configuration.AdminPassword
        //    }
        //};


        #region c-tor & d-tor

        public DAL_XML_imp()
        {
            try
            {
                if (!File.Exists(XmlConfigurations.ConfigPath))
                {
                    SaveConfigurations();
                }
                else
                {
                    LoadOrderXmlFile();
                }

                if (!File.Exists(XmlConfigurations.OrdersPath))
                {
                    XmlConfigurations.OrderRoot = new XElement("Orders");
                    XmlConfigurations.OrderRoot.Save(XmlConfigurations.OrdersPath);
                }

                if (!File.Exists(XmlConfigurations.CustomerPath))
                {
                    Tools.SaveToXML(new List <Customer>(), XmlConfigurations.CustomerPath);
                }

                if (!File.Exists(XmlConfigurations.GuestRequestPath))
                {
                    Tools.SaveToXML(new List <GuestRequest>(), XmlConfigurations.GuestRequestPath);
                }

                if (!File.Exists(XmlConfigurations.HostsPath))
                {
                    Tools.SaveToXML(new List <Host>(), XmlConfigurations.HostsPath);
                }

                if (!File.Exists(XmlConfigurations.SiteOwnerPath))
                {
                    Tools.SaveToXML(_SiteOwner = new SiteOwner()
                    {
                        OwnerLogin = new Login
                        {
                            UserName = Configuration.AdminUser,
                            Password = Configuration.AdminPassword
                        }
                    }, XmlConfigurations.SiteOwnerPath);
                }

                if (!File.Exists(XmlConfigurations.BankBranchesPath))
                {
                    XmlConfigurations.BankBranchesRoot = new XElement("BankBranches");
                    XmlConfigurations.BankBranchesRoot.Save(XmlConfigurations.BankBranchesPath);
                }
                XmlConfigurations.OrderRoot        = XElement.Load(XmlConfigurations.OrdersPath);
                XmlConfigurations.BankBranchesRoot = XElement.Load(XmlConfigurations.BankBranchesPath);
                _customers = Tools.LoadFromXML <List <Customer> >(XmlConfigurations.CustomerPath);
                _guests    = Tools.LoadFromXML <List <GuestRequest> >(XmlConfigurations.GuestRequestPath);
                _hosts     = Tools.LoadFromXML <List <Host> >(XmlConfigurations.HostsPath);
                _SiteOwner = Tools.LoadFromXML <SiteOwner>(XmlConfigurations.SiteOwnerPath);
            }
            catch (Exception)
            {
                //do nothing
            }
        }