Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // check whether user is logged in or not
     try
     {
         if (CookieProxy.Instance().HasKey("t") == false)
         {
             CookieProxy.Instance().SetValue("LoginMessage", "You need to login to view this page", DateTime.Now.AddSeconds(10));
             Response.Redirect("/Signout", false);
         }
         else
         {
             IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
             if (new Security(UserProfileObj).AuthenticateUser() == false)
             {
                 CookieProxy.Instance().SetValue("LoginMessage", "Relogin required to proceed", DateTime.Now.AddSeconds(10));
                 Response.Redirect("/Signout", false);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Warn.Instance(), ex);
         CookieProxy.Instance().SetValue("LoginMessage", "An error occured, this event has been logged", DateTime.Now.AddSeconds(10));
         Response.Redirect("/Signout");
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        List <IUserProfile> FetchAdminList = null;

        try
        {
            UserProfile UserProfileObj = new UserProfile();
            UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
            UserTemplate <IUserProfile> Profile = new AdminUserTemplate(UserProfileObj);
            FetchAdminList = Profile.FetchList();
            if (FetchAdminList == null)
            {
                CookieProxy.Instance().SetValue("LoginMessage", "Unable to authenticate the token, please relogin or check logs", DateTime.Now.AddDays(2));
            }
            Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " fetched admin list "));
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Fatal.Instance(), ex);
        }
        finally
        {
            Response.Write(new JavaScriptSerializer().Serialize(FetchAdminList));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        List <IUserProfile> UserList = null;

        try
        {
            UserProfile UserProfileObj = new UserProfile();
            UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
            UserTemplate <IUserProfile> Profile = new NormalUserTemplate(UserProfileObj, Request.Form["s"]);
            UserList = Profile.FetchList();
            if (UserList == null)
            {
                CookieProxy.Instance().SetValue("LoginMessage", "Unable to authenticate the token, please relogin or check logs", DateTime.Now.AddDays(2));
            }
            Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " searched for user " + Request.Form["s"]));
        }
        catch (Exception ex)
        {
            CookieProxy.Instance().SetValue("LoginMessage", "An Error occured while processing the request, please check logs", DateTime.Now.AddDays(2));
            Logger.Instance().Log(Warn.Instance(), ex);
        }
        finally
        {
            Response.Write(new JavaScriptSerializer().Serialize(UserList));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        string ResponseValue  = "";
        string ResponseString = "";

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                UserProfile UserProfileObj = new UserProfile();
                Category    CategoryObj    = new Category();
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                CategoryObj.SetCategoryId(int.Parse(Request.Form["c"]));
                APIResponse Response = new CategoryBusinessLayerTemplate(UserProfileObj).Delete(CategoryObj);
                ResponseValue = Response.ToString();

                if (Response == APIResponse.NOT_OK)
                {
                    ResponseString = "Unable to delete the category, please check logs";
                }
                else
                {
                    Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " deleted the category ID " + Request.Form["c"].ToString()));
                }
            }
            else
            {
                ResponseValue  = APIResponse.NOT_OK.ToString();
                ResponseString = "NOT_AUTHENTICATED";
            }
        }
        catch (NullReferenceException nex)
        {
            CookieProxy.Instance().SetValue("LoginMessage", "Not Authorized, please login with correct credentials. If you believe this is an error, please check logs".ToString(), DateTime.Now.AddDays(2));
            Logger.Instance().Log(Warn.Instance(), nex);
            ResponseValue  = APIResponse.NOT_OK.ToString();
            ResponseString = "NOT_AUTHENTICATED";
        }
        catch (MySqlException mse)
        {
            Logger.Instance().Log(Warn.Instance(), mse);
            ResponseValue  = APIResponse.NOT_OK.ToString();
            ResponseString = "Unable to delete category, please delete the products first linked to category before deleting category";
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ResponseValue  = APIResponse.NOT_OK.ToString();
            ResponseString = "Unable to delete the category, please check logs";
        }
        finally
        {
            var output = new
            {
                Code     = ResponseValue,
                Response = ResponseString,
            };
            Response.Write(new JavaScriptSerializer().Serialize(output));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        IUserProfile            UserProfileObj = new UserProfile();
        UserProfileMenuResponse ProfileMenu    = new UserProfileMenuResponse();

        try
        {
            ProfileMenu.IsProfileAvailable = false;
            if (CookieProxy.Instance().HasKey("t"))
            {
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                if (CookieProxy.Instance().HasKey("um"))
                {
                    ProfileMenu = new UserActions(UserProfileObj).GetProfileMenu(CookieProxy.Instance().GetValue("um").ToString());
                }
                else
                {
                    ProfileMenu = new UserActions(UserProfileObj).GetProfileMenu(null);
                }
                if (ProfileMenu.ShouldReupdate)
                {
                    RemoveProfileCookie();
                    ProfileMenu = new UserActions(null).GetProfileMenu(null);
                }
                CookieProxy.Instance().SetValue("um", new JavaScriptSerializer().Serialize(ProfileMenu), DateTime.Now.AddDays(2));
            }
        }
        catch (Exception ex)
        {
            ProfileMenu.IsProfileAvailable = false;
        }

        Response.Write(new JavaScriptSerializer().Serialize(ProfileMenu));
    }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse ResponseENUM   = APIResponse.NOT_OK;
        string      ResponseString = "";

        try
        {
            CookieProxy.Instance().RemoveKey("Cart");
            ResponseENUM   = APIResponse.OK;
            ResponseString = "SUCCESS";
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ResponseENUM   = APIResponse.NOT_OK;
            ResponseString = "ERROR";
        }
        finally
        {
            var ReturnObj = new
            {
                Response = ResponseENUM.ToString(),
                ResponseString
            };
            Response.Write(new JavaScriptSerializer().Serialize(ReturnObj));
        }
    }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ApiAuthResponse AuthResponseObj = new ApiAuthResponse();

        try
        {
            UserProfile UserProfileObj          = new UserProfile(Token: CookieProxy.Instance().GetValue("t").ToString(), Email: Request.Form["e"].ToString());
            UserTemplate <IUserProfile> Profile = new AdminUserTemplate(UserProfileObj);
            APIResponse Response = Profile.Remove();
            AuthResponseObj.SetAPIResponse(Response);
            if (Response == APIResponse.NOT_AUTHENTICATED)
            {
                CookieProxy.Instance().SetValue("LoginMessage", "Unable to authenticate the token, please relogin or relogin", DateTime.Now.AddDays(2));
            }

            if (AuthResponseObj.GetAPIResponse() == APIResponse.OK)
            {
                // log the event
                Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " removed " + Request.Form["e"]));
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Info.Instance(), ex);
        }
        finally
        {
            Response.Write(new JavaScriptSerializer().Serialize(AuthResponseObj));
        }
    }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (string key in CookieProxy.Instance().GetAllKeys())
        {
            CookieProxy.Instance().RemoveKey(key);
        }

        // abandon the session
        Session.Abandon();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        bool   HasOrders       = false;
        bool   IsAuthenticated = false;
        string ResponseString  = "";
        List <IOrderBuilderResponse> ListOfOrders = null;

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                IUserProfile UserProfileObj = new UserProfile();
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                // authenticate incoming token
                new Security(UserProfileObj).AuthenticateUser();
                IOrder            OrderObj = new Order();
                OrderTypeTemplate Order    = new IndividualOrderTemplate(UserProfileObj, OrderObj);
                ListOfOrders   = Order.FetchCancelledOrderID();
                ResponseString = "SUCCESS";

                IsAuthenticated = true;
                if (ListOfOrders.Count == 0)
                {
                    HasOrders = false;
                }
                else
                {
                    HasOrders = true;
                }
            }
            else
            {
                ResponseString = "INVALID";
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ResponseString = "Unable to fetch the orders this time, please try again later";
        }
        finally
        {
            var JSONResponse = new
            {
                HasOrders,
                IsAuthenticated,
                Response = ResponseString,
                ListOfOrders
            };

            Response.Write(new JavaScriptSerializer().Serialize(JSONResponse));
        }
    }
Beispiel #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //get the database version
            try
            {
                string DBVersionString = DBVersion.GetDBVersion;

                if (new MaintenanceMode().IsMaintenanceModeEnabled() == APIResponse.OK)
                {
                    if (Page.TemplateControl.AppRelativeVirtualPath != "~/Login.aspx")
                    {
                        CookieProxy.Instance().SetValue("LoginMessage", new SettingsFromDB().FetchSettingsFromDB(new Settings("LOGIN_MAINTENANCE_MESSAGE")).GetSettingsValue(), DateTime.Now.AddDays(2));
                        Response.Redirect("/signout.aspx?r=/Login", false);
                    }
                }

                // here t is the token (if the user has logged in once from this browser)
                UserProfile UserProfileObj = new UserProfile();
                if (CookieProxy.Instance().HasKey("t"))
                {
                    UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                    bool response = new Security(UserProfileObj).AuthenticateUser();
                    if (response == true)
                    {
                        loginLabel.Visible    = false;
                        registerLabel.Visible = false;
                        userProfile.Visible   = true;
                        UserTemplate <IUserProfile> Template = new NormalUserTemplate();
                        userName.Text = Template.FetchParticularProfile(UserProfileObj).GetFirstName();
                    }
                    else
                    {
                        // remove the cookie
                        CookieProxy.Instance().RemoveKey("t");
                        loginLabel.Visible    = true;
                        registerLabel.Visible = true;
                        userProfile.Visible   = false;
                    }
                    SessionProxy.Instance().SetValue("USER.AUTHENTICATED", response, DateTime.Now);
                }
                // load the menu
                LoadMasterMenu();
            }
            catch (Exception ex)
            {
                Logger.Instance().Log(Fatal.Instance(), ex);
                Response.Redirect("~/ErrorPages/Error.aspx?e=500", true);
            }
        }
    }
Beispiel #11
0
    protected void Login_Click(object sender, EventArgs e)
    {
        try
        {
            // get the email and password
            string _Email    = Email.Value;
            string _Password = password.Value;

            UserProfile UserProfileObj = new UserProfile();
            UserProfileObj.SetEmail(_Email);
            UserProfileObj.SetPassword(_Password);

            // now authenticate
            LoginUserReponse response = new UserActions().LoginUserAction(UserProfileObj);

            if (response.GetIsLoggedIn())
            {
                // set authentication cookies and redirect
                CookieProxy.Instance().SetValue("t", response.GetToken(), DateTime.Now.AddYears(1));

                // check the maintenance mode
                if (new MaintenanceMode().IsMaintenanceModeEnabled() == APIResponse.OK)
                {
                    // maintenance mode enabled, check if admin
                    UserProfileObj.SetToken(response.GetToken());
                    if (new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetIsAdmin() == true)
                    {
                        Response.Redirect("/admin-settings", true);
                    }
                }

                // check if there is any redirect on querystring
                if (Request.QueryString["r"] != null)
                {
                    CookieProxy.Instance().SetValue("InternalRedirect", Request.QueryString["r"], DateTime.Now.AddSeconds(10));
                    Response.Redirect("/InternalRedirect");
                }

                Response.Redirect("/Products");
            }
            else
            {
                SetWarningLabel(response.GetErrorText());
            }
        }
        catch (Exception)
        {
            SetWarningLabel("Unable to login to the system, this event has been logged");
        }
    }
Beispiel #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string           ResponseValue  = "";
        string           ResponseString = "";
        List <ICategory> Categories     = null;

        try
        {
            UserProfile UserProfileObj = new UserProfile();
            UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
            Categories = new CategoryBusinessLayerTemplate(UserProfileObj).Select();
            if (null == Categories)
            {
                ResponseValue  = APIResponse.NOT_OK.ToString();
                ResponseString = "NOT_AUTHENTICATED";
                CookieProxy.Instance().SetValue("LoginMessage", "Not Authorized, please login with correct credentials".ToString(), DateTime.Now.AddDays(2));
                Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " fetched category list"));
            }
            else
            {
                Logger.Instance().Log(Info.Instance(), new LogInfo(new AdminUserTemplate().FetchParticularProfile(UserProfileObj).GetEmail() + " fetched category list "));
                ResponseValue  = APIResponse.OK.ToString();
                ResponseString = "SUCCESS";
            }
        }
        catch (NullReferenceException nex)
        {
            CookieProxy.Instance().SetValue("LoginMessage", "Not Authorized, please login with correct credentials. If you believe this is an error, please check logs".ToString(), DateTime.Now.AddDays(2));
            Logger.Instance().Log(Warn.Instance(), nex);
            ResponseValue  = APIResponse.NOT_OK.ToString();
            ResponseString = "NOT_AUTHENTICATED";
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ResponseValue  = APIResponse.NOT_OK.ToString();
            ResponseString = "Unable to fetch the list of categories, please check logs";
        }
        finally
        {
            var output = new
            {
                Code           = ResponseValue,
                Response       = ResponseString,
                CategoriesList = Categories
            };
            Response.Write(new JavaScriptSerializer().Serialize(output));
        }
    }
Beispiel #13
0
    protected void RegisterButton_Click(object sender, EventArgs e)
    {
        string FirstName = firstName.Value;
        string LastName  = lastName.Value;
        string Email     = email.Value;
        string Password  = password.Value;

        // now get all the parameters via post
        try
        {
            UserProfile UserProfileObj = new UserProfile();
            UserProfileObj.SetFirstName(FirstName);
            UserProfileObj.SetLastName(LastName);
            UserProfileObj.SetEmail(Email);
            UserProfileObj.SetPassword(Password);
            UserProfileObj.SetRoleType("NORMAL");
            UserTemplate <IUserProfile> NormalUserTemplate = new NormalUserTemplate(UserProfileObj);
            APIResponse response = NormalUserTemplate.Add();
            if (response == APIResponse.OK)
            {
                // get the token
                List <string> Token  = new Security(UserProfileObj).GetTokenList();
                string        sToken = Token[Token.Count - 1].ToString();
                CookieProxy.Instance().SetValue("t", sToken, DateTime.Now.AddYears(1));
                Response.Redirect("/Products");
            }
            else
            {
                SetWarningLabel("Email already exists, please register with different email");
            }
        }
        catch (MySql.Data.MySqlClient.MySqlException mse)
        {
            if (mse.Number == 1062)
            {
                SetWarningLabel("Email already exists, please register with different email");
            }
            else
            {
                SetWarningLabel("An error occured while connecting to tthe DB, this event has been logged");
            }
        }
        catch (Exception)
        {
            SetWarningLabel("An error occured, please try again later<br> This event has been logged");
            registerButton.Visible = false;
        }
    }
Beispiel #14
0
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse ResponseENUM   = APIResponse.NOT_OK;
        string      ResponseString = "";

        try
        {
            Cart CartObj = null;
            if (CookieProxy.Instance().HasKey("Cart"))
            {
                int PBSId = int.Parse(Request.Form["pbsid"].ToString());
                CartObj = new JavaScriptSerializer().Deserialize <Cart>(CookieProxy.Instance().GetValue("Cart").ToString());
                int Iterator = 0;
                foreach (CartItems Cart in CartObj.CartItems)
                {
                    if (Cart.ProductObj.pbsID == PBSId)
                    {
                        CartObj.CartItems.RemoveAt(Iterator);
                        ResponseENUM   = APIResponse.OK;
                        ResponseString = "SUCCESS";
                        break;
                    }
                    Iterator += 1;
                }
                CookieProxy.Instance().SetValue("Cart", new JavaScriptSerializer().Serialize(CartObj), DateTime.Now.AddDays(5));
            }
            else
            {
                ResponseENUM   = APIResponse.NOT_OK;
                ResponseString = "AN ERROR OCCURED WHILE READING THE CART, PLEASE CLEAR YOUR COOKIES";
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ResponseENUM   = APIResponse.NOT_OK;
            ResponseString = "AN ERROR OCCURED WHILE READING THE CART, PLEASE CLEAR YOUR COOKIES";
        }
        finally
        {
            var ReturnObj = new
            {
                Response = ResponseENUM.ToString(),
                ResponseString
            };
            Response.Write(new JavaScriptSerializer().Serialize(ReturnObj));
        }
    }
Beispiel #15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         UserProfile UserProfileObj = new UserProfile();
         if (CookieProxy.Instance().HasKey("t"))
         {
             UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
             // check if the current user is admin or not
             bool AuthAdminResponseObj = new Security(UserProfileObj).AuthenticateAdmin();
             if (AuthAdminResponseObj == false)
             {
                 CookieProxy.Instance().SetValue("LoginMessage", "Not Authorized, please login with correct credentials".ToString(), DateTime.Now.AddDays(2));
                 Response.Redirect("/signout.aspx", false);
             }
             else
             {
                 UserTemplate <IUserProfile> Template = new AdminUserTemplate();
                 userName.Text = Template.FetchParticularProfile(UserProfileObj).GetFirstName();
             }
         }
         else
         {
             Logger.Instance().Log(Warn.Instance(), new LogDebug("An attempt was made to access the admin panel but failed."));
             CookieProxy.Instance().SetValue("LoginMessage", "Not Authorized, please login with correct credentials".ToString(), DateTime.Now.AddDays(2));
             Response.Redirect("/signout.aspx", false);
         }
     }
     catch (NullReferenceException)
     {
         Logger.Instance().Log(Warn.Instance(), new LogDebug("Unable to authenticate the token, token invalid or not found"));
         CookieProxy.Instance().SetValue("LoginMessage", "Unable to authenticate, please login with correct credentails.".ToString(), DateTime.Now.AddDays(2));
         Response.Redirect("/signout.aspx", false);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Warn.Instance(), ex);
         if (CookieProxy.Instance().HasKey("LoginMessage") == false)
         {
             CookieProxy.Instance().SetValue("LoginMessage", "An error occured while authenticating, this event has been logged".ToString(), DateTime.Now.AddDays(2));
         }
         Response.Redirect("/signout.aspx");
     }
 }
Beispiel #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string LoginMessage = "";

        try
        {
            if (CookieProxy.Instance().HasKey("LoginMessage"))
            {
                LoginMessage = CookieProxy.Instance().GetValue("LoginMessage").ToString();
            }
            // remove the session
            SessionProxy.Instance().RemoveKey("USER.AUTHENTICATED");

            // remove the cookies
            CookieProxy.Instance().RemoveKey("t");
            CookieProxy.Instance().RemoveKey("um");

            // redirect to login
            if (Request.QueryString["r"] != null)
            {
                // set the redirect cookie
                CookieProxy.Instance().SetValue("InternalRedirect", Request.QueryString["r"], DateTime.Now.AddSeconds(10));
                Response.Redirect("/InternalRedirect");
            }
            UserProfile UserProfileObj = new UserProfile();
            if (CookieProxy.Instance().HasKey("t"))
            {
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                new Security(UserProfileObj).RemoveTokenFromDB();
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
        }
        finally
        {
            if (LoginMessage != "")
            {
                CookieProxy.Instance().SetValue("LoginMessage", LoginMessage, DateTime.Now.AddDays(2));
            }
        }
        Response.Redirect("/login");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        bool            isAuthenticated = false;
        List <IAddress> AddressList     = new List <IAddress>();

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                IUserProfile UserProfileObj = new UserProfile();
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                CRUDBusinessLayerTemplate <IAddress> AddressObj = new AddressBusinessLayerTemplate(UserProfileObj);
                AddressList     = AddressObj.Select();
                isAuthenticated = true;
            }
            else
            {
                isAuthenticated = false;
            }
        }
        catch (NullReferenceException)
        {
            isAuthenticated = false;
            CookieProxy.Instance().SetValue("LoginMessage", "For security reasons, please relogin", DateTime.Now.AddDays(2));
        }
        catch (Exception)
        {
            isAuthenticated = false;
            CookieProxy.Instance().SetValue("LoginMessage", "An error occured, this event has been logged. Please try again later", DateTime.Now.AddDays(2));
        }
        finally
        {
            var JSONResponse = new
            {
                isAuthenticated,
                AddressList
            };

            Response.Write(new JavaScriptSerializer().Serialize(JSONResponse));
        }
    }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse ResponseAPI = APIResponse.NOT_OK;

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
                ICardDetails CardObj        = new CardDetails(int.Parse(Request.Form["cid"].ToString()));
                CRUDBusinessLayerTemplate <ICardDetails> CardCRUD = new CardDetailsBusinessLayerTemplate(UserProfileObj);
                ResponseAPI = CardCRUD.Delete(CardObj);
            }
            else
            {
                ResponseAPI = APIResponse.NOT_AUTHENTICATED;
            }
        }
        catch (NullReferenceException)
        {
            ResponseAPI = APIResponse.NOT_AUTHENTICATED;
        }
        catch (Exception)
        {
            ResponseAPI = APIResponse.NOT_OK;
        }
        finally
        {
            if (ResponseAPI == APIResponse.NOT_AUTHENTICATED)
            {
                CookieProxy.Instance().SetValue("LoginMessage", "For security reasons, please relogin".ToString(), DateTime.Now.AddDays(2));
            }

            var ResponseObj = new
            {
                Response = ResponseAPI.ToString()
            };

            Response.Write(new JavaScriptSerializer().Serialize(ResponseObj));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse ResponseAPI = APIResponse.NOT_OK;

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
                IAddress     AddressObj     = new Address(Request.Form["Name"].ToString(), Request.Form["Street"].ToString(), Request.Form["Appt"].ToString(), Request.Form["PostalCode"].ToString(), Request.Form["PhoneNumber"].ToString(), int.Parse(Request.Form["c"]));
                CRUDBusinessLayerTemplate <IAddress> AddressCRUD = new AddressBusinessLayerTemplate(UserProfileObj);
                ResponseAPI = AddressCRUD.Insert(AddressObj);
            }
            else
            {
                ResponseAPI = APIResponse.NOT_AUTHENTICATED;
            }
        }
        catch (NullReferenceException)
        {
            ResponseAPI = APIResponse.NOT_AUTHENTICATED;
        }
        catch (Exception)
        {
            ResponseAPI = APIResponse.NOT_OK;
        }
        finally
        {
            if (ResponseAPI == APIResponse.NOT_AUTHENTICATED)
            {
                CookieProxy.Instance().SetValue("LoginMessage", "For security reasons, please relogin".ToString(), DateTime.Now.AddDays(2));
            }

            var ResponseObj = new
            {
                Response = ResponseAPI.ToString()
            };

            Response.Write(new JavaScriptSerializer().Serialize(ResponseObj));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // internal redirect
        // check if the cookies exists
        object OInternalRedirectCookie = CookieProxy.Instance().GetValue("InternalRedirect");

        if (OInternalRedirectCookie == null)
        {
            // redirect to home
            Response.Redirect("/");
        }

        string InternalRedirectCookie = OInternalRedirectCookie.ToString();

        // check for logic whether is there a suspicous link
        // end of check

        // remove the cookie
        CookieProxy.Instance().RemoveKey("InternalRedirect");
        Response.Redirect(InternalRedirectCookie);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        bool HasCityList = false;
        Dictionary <int, string> CityList = new Dictionary <int, string>();
        CityList ListOfCities             = new CityList();

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                ListOfCities.ListOfCities = new List <City>();
                IUserProfile UserProfileObj = new UserProfile();
                UserProfileObj.SetToken(CookieProxy.Instance().GetValue("t").ToString());
                CityList = new Province(UserProfileObj).GetCityList(Request.Form["province"]);
                foreach (KeyValuePair <int, string> pair in CityList)
                {
                    ListOfCities.ListOfCities.Add(new City(pair.Key, pair.Value));
                }
                HasCityList = true;
            }
            else
            {
                HasCityList = true;
            }
        }
        catch (Exception)
        {
            HasCityList = false;
        }
        finally
        {
            var output = new
            {
                HasCityList,
                ListOfCities
            };
            Response.Write(new JavaScriptSerializer().Serialize(output));
        }
    }
Beispiel #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ApiAuthResponse AuthResponseObj = new ApiAuthResponse();

        try
        {
            UserProfile UserProfileObj          = new UserProfile(Token: CookieProxy.Instance().GetValue("t").ToString(), Email: Request.Form["e"].ToString());
            UserTemplate <IUserProfile> Profile = new AdminUserTemplate(UserProfileObj);
            APIResponse ResponseObj             = Profile.Add();
            AuthResponseObj.SetAPIResponse(ResponseObj);
            if (ResponseObj == APIResponse.OK)
            {
                // log the event
                Logger.Instance().Log(Info.Instance(), new LogInfo(Profile.FetchParticularProfile(UserProfileObj).GetEmail() + " added " + Request.Form["e"]));
            }
        }
        catch (Exception ex)
        {
            AuthResponseObj.SetAPIResponse(APIResponse.NOT_OK);
            Logger.Instance().Log(Fatal.Instance(), ex);
        }
        Response.Write(new JavaScriptSerializer().Serialize(AuthResponseObj));
    }
Beispiel #23
0
    protected override void OnLoadComplete(EventArgs e)
    {
        base.OnLoadComplete(e);
        if (!Page.IsPostBack)
        {
            if (SessionProxy.Instance().HasKey("USER.AUTHENTICATED"))
            {
                if (CookieProxy.Instance().HasKey("t"))
                {
                    if ((bool)SessionProxy.Instance().GetValue("USER.AUTHENTICATED") == true)
                    {
                        // check if there is any redirect on querystring
                        if (Request.QueryString["r"] != null)
                        {
                            SessionProxy.Instance().SetValue("InternalRedirect", Request.QueryString["r"], DateTime.Now.AddSeconds(10));
                            Response.Redirect("/InternalRedirect");
                        }
                        Response.Redirect("/Products");
                    }
                }
                else
                {
                    Response.Redirect("/Signout");
                }
            }
        }

        // check if there is any loginmessage cookie
        if (CookieProxy.Instance().HasKey("LoginMessage"))
        {
            LoginMessage.InnerText = CookieProxy.Instance().GetValue("LoginMessage").ToString();
            LoginMessage.Visible   = true;

            // remove this key
            CookieProxy.Instance().RemoveKey("LoginMessage");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        bool IsAuthenticated = false;

        try
        {
            if (CookieProxy.Instance().HasKey("t"))
            {
                IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
                if (new Security(UserProfileObj).AuthenticateUser() == false)
                {
                    IsAuthenticated = false;
                }
                else
                {
                    IsAuthenticated = true;
                }
            }
            else
            {
                IsAuthenticated = false;
            }
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            IsAuthenticated = false;
        }
        finally
        {
            var Output = new
            {
                IsAuthenticated
            };
            Response.Write(new JavaScriptSerializer().Serialize(Output));
        }
    }
Beispiel #25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse         ResponseAPI = APIResponse.NOT_OK;
        IOrderCreaterStatus OrderStatus = null;

        try
        {
            ICart        CartObj        = new JavaScriptSerializer().Deserialize <Cart>(CookieProxy.Instance().GetValue("Cart").ToString());
            IAddress     AddressObj     = new Address(int.Parse(Request.Form["aid"].ToString()));
            ICardDetails CardObj        = new CardDetails(int.Parse(Request.Form["cID"].ToString()));
            IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
            OrderStatus = new OrderCreator().CreateOrder(AddressObj, CardObj, UserProfileObj, CartObj);
            if (OrderStatus.GetIsOrderCreated() == true)
            {
                // empty the cart
                CookieProxy.Instance().RemoveKey("Cart");
                ResponseAPI = APIResponse.OK;
            }
            else
            {
                ResponseAPI = APIResponse.NOT_OK;
            }
        }
        catch (Exception)
        {
            ResponseAPI = APIResponse.NOT_OK;
        }
        finally
        {
            var ResponseObj = new
            {
                Response = ResponseAPI.ToString(),
                data     = OrderStatus
            };
            Response.Write(new JavaScriptSerializer().Serialize(ResponseObj));
        }
    }
Beispiel #26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ITaxResult TaxResultObj = null;

        try
        {
            Cart         CartObj        = new JavaScriptSerializer().Deserialize <Cart>(CookieProxy.Instance().GetValue("Cart").ToString());
            IAddress     AddressObj     = new Address(int.Parse(Request.Form["aid"].ToString()));
            IUserProfile UserProfileObj = new UserProfile(CookieProxy.Instance().GetValue("t").ToString());
            TaxResultObj = new TaxManagement().CalculateTaxFromCartItems(CartObj, AddressObj, UserProfileObj);
        }
        catch (Exception)
        {
            TaxResultObj = new TaxResult(false);
        }
        finally
        {
            var ResultObj = new
            {
                Response = TaxResultObj
            };
            Response.Write(new JavaScriptSerializer().Serialize(ResultObj));
        }
    }
 protected void Btn_update_txt_Regex_invalid_password_Click(object sender, EventArgs e)
 {
     try
     {
         TextStatus.Text      = "UPDATED";
         TextStatus.BackColor = System.Drawing.Color.FromArgb(Int32.Parse("26A69A", NumberStyles.HexNumber));
         TextStatus.ForeColor = System.Drawing.Color.White;
         TextStatus.Visible   = true;
         new SettingsFromDB().UpdateSettingsFromDB(new Settings("REGEX_PASSWORD_ERROR_TEXT", txt_regex_invalid_password_text.Text.ToString()));
         Logger.Instance().Log(Info.Instance(), new WarnDebug(new NormalUserTemplate().FetchParticularProfile(new UserProfile(CookieProxy.Instance().GetValue("t").ToString())).GetEmail() + " updated REGEX Password Error Text to  : " + txt_regex_invalid_password_text.Text.ToString()));
     }
     catch (Exception ex)
     {
         TextStatus.Visible   = true;
         TextStatus.Text      = ex.Message.ToString();
         TextStatus.BackColor = System.Drawing.Color.FromArgb(Int32.Parse("FF6E6E", NumberStyles.HexNumber));
         TextStatus.ForeColor = System.Drawing.Color.White;
     }
 }
 private void RemoveProfileCookie()
 {
     CookieProxy.Instance().RemoveKey("um");
 }
Beispiel #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        APIResponse ApiResponse = APIResponse.NOT_OK;
        int         Quantity    = 0;
        Cart        CartObj     = new Cart();

        try
        {
            if (CookieProxy.Instance().HasKey("Cart"))
            {
                CartObj = new JavaScriptSerializer().Deserialize <Cart>(CookieProxy.Instance().GetValue("Cart").ToString());
                foreach (CartItems Items in CartObj.CartItems)
                {
                    IProductByStore PBSObj = new ProductByStore();
                    PBSObj.SetProductByStoreID(Items.ProductObj.pbsID);
                    Products DBProductQty = new ProductByStoreBusinessLayerTemplate().Select(PBSObj);
                    if (GetMaxQty < DBProductQty.Quantity)
                    {
                        Items.DBQuantity = GetMaxQty;
                    }
                    else
                    {
                        Items.DBQuantity = DBProductQty.Quantity;
                    }
                    if (Items.ProductObj.Quantity < 0)
                    {
                        CartObj.HasValidationErrors = true;
                        Items.ProductObj.Quantity   = -1;
                        Items.HasQuantity           = false;
                    }
                    else
                    if (DBProductQty.Quantity < Items.ProductObj.Quantity && Items.ProductObj.Quantity <= 0)
                    {
                        CartObj.HasValidationErrors = true;
                        Items.ProductObj.Quantity   = -1;
                        Items.HasQuantity           = false;
                    }
                    else if (DBProductQty.Quantity < Items.ProductObj.Quantity)
                    {
                        CartObj.HasValidationErrors = true;
                        Items.HasQuantity           = false;
                    }
                    Quantity = CartObj.CartItems.Count;
                }
            }
            ApiResponse = APIResponse.OK;
        }
        catch (Exception ex)
        {
            Logger.Instance().Log(Warn.Instance(), ex);
            ApiResponse = APIResponse.NOT_OK;
        }
        finally
        {
            var Cart = new
            {
                Response = ApiResponse.ToString(),
                Quantity,
                Cart = new JavaScriptSerializer().Serialize(CartObj)
            };
            Response.Write(new JavaScriptSerializer().Serialize(Cart));
        }
    }
 protected void Btn_update_regex_postalcode_Click(object sender, EventArgs e)
 {
     try
     {
         TextStatus.Text      = "UPDATED";
         TextStatus.BackColor = System.Drawing.Color.FromArgb(Int32.Parse("26A69A", NumberStyles.HexNumber));
         TextStatus.ForeColor = System.Drawing.Color.White;
         TextStatus.Visible   = true;
         new SettingsFromDB().UpdateSettingsFromDB(new Settings("REGEX_POSTAL_CODE", txt_regex_postalcode.Text.ToString()));
         Logger.Instance().Log(Info.Instance(), new WarnDebug(new NormalUserTemplate().FetchParticularProfile(new UserProfile(CookieProxy.Instance().GetValue("t").ToString())).GetEmail() + " updated HOME Page value to  : " + DropDownEnableHomePage.Text.ToString()));
     }
     catch (Exception ex)
     {
         TextStatus.Visible   = true;
         TextStatus.Text      = ex.Message.ToString();
         TextStatus.BackColor = System.Drawing.Color.FromArgb(Int32.Parse("FF6E6E", NumberStyles.HexNumber));
         TextStatus.ForeColor = System.Drawing.Color.White;
     }
 }