/// <summary>
 /// Deprecated Method for adding a new object to the Earnings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEarnings(Earning earning)
 {
     base.AddObject("Earnings", earning);
 }
        public MembershipCreateStatus bCreateUser(string CompanyName, string Username, string Password, string Email, string TaxCode, string Phone)
        {
            if (String.IsNullOrEmpty(CompanyName)) throw new ArgumentException("Value cannot be null or empty.", "CompanyName");
            if (String.IsNullOrEmpty(Username)) throw new ArgumentException("Value cannot be null or empty.", "UserName");
            if (String.IsNullOrEmpty(Email)) throw new ArgumentException("Value cannot be null or empty.", "Email");
            if (String.IsNullOrEmpty(Password)) throw new ArgumentException("Value cannot be null or empty.", "Password");

            MembershipCreateStatus status;

            var checkUser = from m in StoreDb.Webmasters
                            where (m.Username == Username)
                            select m;
            if (checkUser.Count() != 0)
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return status;
            }
            var checkEmail = from m in StoreDb.Webmasters
                             where (m.Email == Email)
                             select m;
            if (checkEmail.Count() != 0)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return status;
            }

            Webmaster web = new Webmaster();
            web.Username = Username;
            web.FirstName = CompanyName;
            web.CompanyName = CompanyName;
            web.Password = Password;
            web.Phone = Phone;
            web.Email = Email;
            web.Status = 0;
            web.DateJoin = DateTime.Now;
            web.AccountType = 1; //0 la personal account  1 la bussiness account
            web.TaxCode = TaxCode;

            string hash = MPHash.hash(Username + Password);
            web.VerifyCode = hash;

            StoreDb.Webmasters.AddObject(web);
            StoreDb.SaveChanges();

            status = MembershipCreateStatus.Success;

            //Tao bang Earning tuong ung
            var checknow = StoreDb.Webmasters.Single(m => m.Username == Username);

            Earning e = new Earning();
            e.Amount = 0;
            e.Currency = "VND";
            e.WebmasterId = checknow.Id;
            e.Status = 0;//keep money
            StoreDb.Earnings.AddObject(e);
            StoreDb.SaveChanges();

            //tao Role cho user nay
            string[] webmaster = new string[] { "Webmaster" };
            string[] user = new string[] { Username };
            MyRoleProvider role = new MyRoleProvider();
            role.AddUsersToRoles(user, webmaster);

            //tao Setting table cho webmaster nay
            int webmt = StoreDb.Webmasters.Single(w => w.Username == Username).Id;
            Setting set = new Setting();
            set.WebmasterId = webmt;
            set.Language = "EN";//default is EN
            StoreDb.Settings.AddObject(set);
            StoreDb.SaveChanges();


            return status;

        }
 /// <summary>
 /// Create a new Earning object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="webmasterId">Initial value of the WebmasterId property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static Earning CreateEarning(global::System.Int32 id, global::System.Int32 webmasterId, global::System.Int32 amount, global::System.Int32 status)
 {
     Earning earning = new Earning();
     earning.Id = id;
     earning.WebmasterId = webmasterId;
     earning.Amount = amount;
     earning.Status = status;
     return earning;
 }