Example #1
0
        public UserController searchByEmail(string email)
        {
            bool wasOpen = true;

            if (conn != null && conn.State == ConnectionState.Closed)
            {
                conn.Open();
                wasOpen = false;
            }
            string     strSelect = "Select * From StoreOwner where email=@email";
            SqlCommand cmd       = new SqlCommand(strSelect, conn);

            cmd.Parameters.Add("@email", email);
            SqlDataReader myReader = cmd.ExecuteReader();

            if (myReader.Read())
            {
                string Nemail   = myReader["email"].ToString();
                string userName = myReader["userName"].ToString();
                string password = myReader["password"].ToString();
                List <StoreController> stores     = new RegisteredStoresController().listStoresOfOwner(email);
                StoreOwnerController   storeOwner = new StoreOwnerController(email, userName, password, stores); conn.Close();
                return(storeOwner);
            }
            if (!wasOpen)
            {
                conn.Close();
            }
            return(null);
        }
        public UserController registerStoreOwnerForOnSiteStore(string email, string userName, string password, string storeName, string storeAddress, [FromBody] string value)
        {
            UserController user = userFinder.findUser(email);

            if (user != null)
            {
                return(null);
            }

            Store store = onsiteStoreSearcher.searchStoreByName(storeName);

            if (store != null)
            {
                return(null);
            }

            StoreOwnerController storeOwnerUser = new StoreOwnerController(email, userName, password);

            OnSiteStore onSiteStore = new OnSiteStore(storeName, storeAddress, storeOwnerUser.getStoreOwner());

            onsiteStoreAdder.addStore(onSiteStore);

            storeOwnerUser.addStore(onSiteStore);

            storeOwnerRepo.addUser(storeOwnerUser.getStoreOwner());
            return(storeOwnerUser);
        }