コード例 #1
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            string requiredPermission = String.Format("{0}-{1}",
                                                      filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
                                                      filterContext.ActionDescriptor.ActionName);


            Orm_Tool.Views.All_Account member = sescon.GetMemberData();
            if (member != null)
            {
                if (!member.ProfileType.Equals("M"))
                {
                    filterContext.Result = new RedirectToRouteResult(
                        new RouteValueDictionary {
                        { "action", "Index" },
                        { "controller", "Home" }
                    });
                }
            }

            else
            {
                filterContext.Result = new RedirectToRouteResult(
                    new RouteValueDictionary {
                    { "action", "Login" },
                    { "controller", "Account" }
                });
            }
        }
コード例 #2
0
        public string AddRating(string Rating, string comment, string CatererId)
        {
            Views.All_Account mem = sescon.GetMemberData();

            try
            {
                decimal Rating_D    = Convert.ToDecimal(Rating);
                int     CatererId_I = Convert.ToInt32(CatererId);

                string status = Sp.MyProc.AddCatererRating(Rating_D, comment, Convert.ToInt32(mem.ID.Split('-')[0]), CatererId_I).ToString();
                if (status.Equals("Operation Successfull !"))
                {
                    return("[{\"returntype\":\"success\",\"message\":\"Your Feedback Submitted Successfully.\"}]");
                }

                else
                {
                    return("[{\"returntype\":\"error\",\"message\":\"Some thing went wrong while processing your request.\"}]");
                }
            }
            catch (Exception ex)
            {
                return("[{\"returntype\":\"error\",\"message\":\"" + HttpUtility.JavaScriptStringEncode(ex.Message + " " + ex.StackTrace) + "\"}]");
            }
        }
コード例 #3
0
        public string GetCatererLists(string json)
        {
            try
            {
                Views.All_Account ac = sescon.GetMemberData();

                if (!json.Equals(""))
                {
                    dynamic param    = JObject.Parse(json);
                    string  Country  = param.Country == null ? "Pakistan" : param.Country.ToString();
                    string  City     = param.City == null ? "Islamabad" : param.City.ToString();
                    bool    IsFilter = param.IsFilter == null ? false : Convert.ToBoolean(param.IsFilter);
                    int     Page     = param.Page == null ? 1 : Convert.ToInt32(param.Page);

                    if (ac != null && IsFilter == false)
                    {
                        City    = ac.City;
                        Country = ac.Country;
                    }

                    return(Sp.MyProc.GetCatererLists(Country, City, IsFilter, Page));
                }

                return(Sp.MyProc.GetCatererLists("Pakistan", "Islamabad"));
            }
            catch (Exception ex)
            {
                return("[{\"Error\",\"" + HttpUtility.JavaScriptStringEncode(ex.Message + " " + ex.StackTrace) + "\"}]");
            }
        }
コード例 #4
0
        public Views.All_Account GetMemberData()
        {
            Views.All_Account memdata = null;

            try
            {
                HttpCookie cookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (cookie != null)
                {
                    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);

                    memdata = new JavaScriptSerializer().Deserialize(ticket.UserData, typeof(Views.All_Account)) as Views.All_Account;
                }
            }
            catch (Exception ex)
            {
            }

            return(memdata);
        }
コード例 #5
0
        public void SetAuthenticationToken(string name, bool isPersistant, Views.All_Account empData)
        {
            string data = null;

            if (empData != null)
            {
                data = new JavaScriptSerializer().Serialize(empData);
            }

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, name, DateTime.Now, DateTime.Now.AddYears(1), isPersistant, data);

            string     cookieData = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie     = new HttpCookie(FormsAuthentication.FormsCookieName, cookieData)
            {
                HttpOnly = true,
                Expires  = ticket.Expiration
            };

            HttpContext.Current.Response.Cookies.Add(cookie);
        }