private StoreManagerDashboardViewModel SetDashBoardModel(StoreManager curSM)
        {
            StoreManagerDashboardViewModel model = new StoreManagerDashboardViewModel();
            User userInfo = UserBUS.GetObject(curSM.UserId);

            model.Id = curSM.UserId;
            model.Name = userInfo.Username;
            model.Status = StoreManagerStateBUS.GetObject((int)curSM.StatusId).Code; //.GetCode((int)curSM.StatusId);
            model.TotalLastMonthAmount = StoreManagerBUS.GetTotalLastMonthAmount(curSM.UserId);
            model.TotalTransaction = StoreManagerBUS.GetTotalLastMonthTransaction(curSM.UserId);

            if (curSM.LastCollectDate != null)
            {
                model.LastCollectDate = (DateTime)curSM.LastCollectDate;
            }
            return model;
        }
        public static bool Update(StoreManager entity)
        {
            //throw new Exception("chua lam!...");
            MoneyPacificDataContext mpdb = new MoneyPacificDataContext();
            StoreManager existSM = mpdb.StoreManagers
                .Where(s => s.UserId.Equals(entity.UserId))
                .Single<StoreManager>();

            existSM.Address = entity.Address;
            existSM.Address2 = entity.Address2;
            existSM.AreaId = entity.AreaId;
            existSM.Country = entity.Country;
            existSM.EmailBill = entity.EmailBill;
            existSM.IdShop = entity.IdShop;
            existSM.IsLocked = entity.IsLocked;
            existSM.LastCollectDate = entity.LastCollectDate;
            existSM.LegalStructure = entity.LegalStructure;
            existSM.ManagerPhone = entity.ManagerPhone;
            existSM.NameOfCompany = entity.NameOfCompany;
            existSM.NameOfStore = entity.NameOfStore;
            existSM.NumberOfShop = entity.NumberOfShop;
            existSM.Phone = entity.Phone;
            existSM.Phone2 = entity.Phone2;
            existSM.Product = entity.Product;
            existSM.ShopSize = entity.ShopSize;
            existSM.StatusId = entity.StatusId;
            existSM.StoreInternetAccessId = entity.StoreInternetAccessId;
            existSM.UserId = entity.UserId;
            existSM.VATNumber = entity.VATNumber;
            existSM.Website = entity.Website;
            existSM.Zip = entity.Zip;

            mpdb.SubmitChanges();          

            mpdb.Connection.Close();
            return true;
        }
 public static bool AddNew(StoreManager entity)
 {
     throw new Exception("chua lam!...");
 }
        private StoreManagerInformationViewModel SetInformationModel(StoreManager curSM)
        {
            StoreManagerInformationViewModel model = new StoreManagerInformationViewModel();
            User userInfo = UserDAO.GetObject(curSM.UserId);

            // Manager Information
            model.Manager = new ManagerInformation();

            model.Manager.Name = userInfo.Firstname + " " + userInfo.Lastname;

            model.Manager.Username = userInfo.Username;
            model.Manager.Password = userInfo.Password;

            model.Manager.NameOfStore = curSM.NameOfStore;
            model.Manager.ManagerPhone = curSM.ManagerPhone;

            model.Manager.Address = curSM.Address;
            model.Manager.Address2 = curSM.Address2;

            model.Manager.Phone = curSM.Phone;
            model.Manager.Phone2 = curSM.Phone2;

            //model.Manager.City = AreaBUS.GetObject(curSM.AreaId).Name;
            //model.Manager.Area = AreaBUS.GetObject((int)curSM.AreaId).Name;
            model.Manager.Area = "HC1 (tmp)";
            model.Manager.Country = curSM.Country;

            model.Manager.EmailAlert = userInfo.Email; // mail lay thong bao
            model.Manager.EmailBill = curSM.EmailBill;

            model.Manager.NameOfCompany = curSM.NameOfCompany;
            model.Manager.VATNumber = curSM.VATNumber;

            // List StoreUser Information
            StoreUser[] arrStoreUser = StoreUserBUS.GetArray(curSM.UserId);
            List<UserInformation> lstUser = new List<UserInformation>();

            foreach (StoreUser store in arrStoreUser)
            {
                User storeUserInfo = UserBUS.GetObject(store.UserId);

                UserInformation newUserPhone = new UserInformation();

                newUserPhone.Email = storeUserInfo.Email;
                newUserPhone.Name = storeUserInfo.Username;
                newUserPhone.Password = storeUserInfo.Password;

                newUserPhone.LastTransaction = "...";

                newUserPhone.Phone = store.Phone;
                newUserPhone.PINStore = store.PINStore;

                //newUserPhone.Status = store.StoreUserState.Code + " - " + store.StoreUserState.Description;                
                StoreUserState storeUserState = StoreUserStateBUS.GetObject((int)store.StatusId);
                newUserPhone.Status = storeUserState.Code + " - " + storeUserState.Description;

                lstUser.Add(newUserPhone);
            }

            model.ArrUser = lstUser.ToArray();

            return model;
        }
 public ActionResult AskToBePartner(StoreManager model)
 {
     return View();
 }
 partial void UpdateStoreManager(StoreManager instance);
 partial void InsertStoreManager(StoreManager instance);
		private void detach_StoreManagers(StoreManager entity)
		{
			this.SendPropertyChanging();
			entity.StoreManagerState = null;
		}
		private void attach_StoreManagers(StoreManager entity)
		{
			this.SendPropertyChanging();
			entity.Area = this;
		}
 partial void DeleteStoreManager(StoreManager instance);