public ActionResult CreateNewSalesman(string username, string password, string fullname, string address, string phonenumber, string coordinate, string email)
        {
            Account salesman = new Account();
            AccountProfile salesmanProfile = new AccountProfile();
            salesman.Email = email;
            salesman.RoleID = 2;

            salesman.Password = md5(password);
            //salesmanProfile.Email = email;
            salesmanProfile.Phone = phonenumber;
            salesmanProfile.FullName = fullname;
            salesmanProfile.Address = address;
            salesmanProfile.Coordinate = coordinate;
            salesman.IsActive = true;
            salesman.IsPending = true;
            salesman.AccountProfile = salesmanProfile;
            unitOfWork.AccountRepository.Insert(salesman);
            unitOfWork.AccountRepository.SaveChanges();

            return RedirectToAction("ManageStaff", "Admin");
        }
        public ActionResult RegisterDrugstoreAccount(string username, string password, string fullname, string email, string phonenumber, string drugstoreName, string drugstoreAddress, string coordinate, int districtID)
        {
            var account = new Account();
            var accountInfo = new AccountProfile();
            var drugstore = new Drugstore();
            account.Email = email;
            account.RoleID = 4;
            //var md5Hasher = new MD5CryptoServiceProvider();

            //var encoder = new UTF8Encoding();
            //var hashed = md5Hasher.ComputeHash(encoder.GetBytes(password)).ToString();
            account.Password = md5(password);
            //accountInfo.Email = email;
            accountInfo.Phone = phonenumber;
            accountInfo.FullName = fullname;
            account.Role = unitOfWork.RoleRepository.Get(b => b.RoleID == 4).SingleOrDefault();
            account.IsActive = true;
            account.IsPending = true;
            account.AccountProfile = accountInfo;
            //account.AccountProfiles.Add(accountInfo);
            var checkUser = unitOfWork.AccountRepository.Get(b => b.Email == email).SingleOrDefault();
            //Check if already have that email
            if (checkUser == null)
            {
                var drugstoreTemp = unitOfWork.DrugStoreRepository.Get(b => b.DrugstoreName == drugstoreName && b.Coordinate == coordinate).FirstOrDefault();
                //Check if already have that drugstore
                if (drugstoreTemp != null)
                {
                    //var ownerDrugstore = unitOfWork.AccountRepository.Get(b => b.DrugstoreID == drugstoreTemp.DrugstoreID).SingleOrDefault();
                    //Check if that drugstore already have owner
                    if (drugstoreTemp.OwnerID == null)
                    {

                        //account.DrugstoreID = drugstoreTemp.DrugstoreID;
                        unitOfWork.AccountRepository.Insert(account);
                        unitOfWork.AccountRepository.SaveChanges();
                        var accountDrugstore = unitOfWork.AccountRepository.Get(b => b.Email == account.Email).SingleOrDefault();
                        if (accountDrugstore != null)
                        {
                            drugstoreTemp.OwnerID = accountDrugstore.AccountID;
                            unitOfWork.DrugStoreRepository.Update(drugstoreTemp);
                            unitOfWork.DrugStoreRepository.SaveChanges();
                        }

                        return Json(new { type = "Successful" });
                    }
                    else
                    {
                        return Json(new { type = "DrugstoreAlreadyHaveAccount", message = "Thông tin nhà thuốc bạn vừa đăng ký đã có trong hệ thống." });
                    }

                }
                //Dont have that drugstore
                drugstore.DrugstoreName = drugstoreName;
                drugstore.DistrictID = districtID;
                drugstore.Address = drugstoreAddress;
                drugstore.DrugstoreTypeID = unitOfWork.DrugStoreTypeRepository.GetByID(3).DrugstoreTypeID;
                //drugstore.Debt = 0;
                drugstore.Coordinate = coordinate;
                //drugstore.Debt = 0;
                drugstore.IsActive = true;
                //drugstore.OwnerID = account.AccountID;
                //account.Drugstore=drugstore;
                unitOfWork.AccountRepository.Insert(account);
                unitOfWork.AccountRepository.SaveChanges();
                var accountTemp = unitOfWork.AccountRepository.Get(b => b.Email == account.Email).SingleOrDefault();
                if (accountTemp != null)
                {
                    drugstore.OwnerID = accountTemp.AccountID;
                    unitOfWork.DrugStoreRepository.Insert(drugstore);
                    unitOfWork.DrugStoreRepository.SaveChanges();
                }

                return Json(new { type = "Successful" });
            }
            return Json(new
            {
                type = "Fail",
                message = "Tên tài khoản này đã có người sử dụng.Xin thử lại bằng tên khác!"
            });
        }