Ejemplo n.º 1
0
        public async Task <JsonResult> DeclineOrder(int?OrderId)
        {
            UserRootObject lRole  = new UserRootObject();
            Response       result = new Response();

            ViewBag.LoginID  = Session["LoginID"].ToString();
            ViewBag.Username = Session["Username"].ToString();
            ViewBag.OrderId  = OrderId;
            string strurl = GetUrl(2);

            strurl = strurl + "UserLogin/DeclineOrder?orderid=" + OrderId;
            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage CustomerresponseMessage = await client.GetAsync(strurl);

                if (CustomerresponseMessage.IsSuccessStatusCode)
                {
                    var response = CustomerresponseMessage.Content.ReadAsStringAsync().Result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    lRole  = JsonConvert.DeserializeObject <UserRootObject>(response, settings);
                    result = lRole.response;
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
    public static string UserFieldModel(User user)
    {
        UserFields fields = new UserFields
        {
            email = new Email {
                stringValue = user.email
            },
            local_id = new LocalId {
                stringValue = user.local_id
            },
            phone_no = new PhoneNo {
                stringValue = user.local_id
            },
            username = new Username {
                stringValue = user.username
            },
            wallet_balance = new WalletBalance {
                doubleValue = user.wallet_balance
            }
        };

        UserRootObject rootObject = new UserRootObject
        {
            fields = fields
        };

        fsData data;

        serializer.TrySerialize(typeof(UserRootObject), rootObject, out data).AssertSuccessWithoutWarnings();

        string post_data = data.ToString();

        return(post_data);
    }
Ejemplo n.º 3
0
        public static List <User> GetUsers(IConfiguration config, string token)
        {
            UserRootObject data         = new UserRootObject();
            string         graphQLQuery = "{\"query\":\"query { users(options: { limit: 50} value: { }) { values { id email ip} } }\"}";

            var baseUrl  = config.GetSection("Astra").GetSection("BaseUrl").Value;
            var keyspace = config.GetSection("Astra").GetSection("Keyspace").Value;
            var url      = string.Format("{0}{1}",
                                         baseUrl, keyspace);

            var client = new RestClient(url);

            client.Timeout = -1;
            var request = new RestRequest(Method.POST);

            request.AddHeader("X-Cassandra-Token", token);
            request.AddParameter("application/json", graphQLQuery, ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            data = JsonConvert.DeserializeObject <UserRootObject>(response.Content);

            Console.WriteLine("retrieved Users: ");

            return(data.data.users.values.ToList());
        }
        public async Task <ActionResult> Userlogin(UserLoginViewModel login, string returnUrl = null)
        {
            if (ModelState.IsValid)
            {
                string url = GetUrl(2);

                url = url + "UserLogin/WebsiteLogin?username="******"&password="******"&storeid=" + login.StoreName + "";
                UserRootObject lRole = new UserRootObject();
                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var result = responseMessage.Content.ReadAsStringAsync().Result;
                        lRole = JsonConvert.DeserializeObject <UserRootObject>(result);
                        if (lRole.response.isSuccess == true)
                        {
                            if (lRole.data.StoreId == 0 && lRole.data.FirstName == "Admin")
                            {
                                Session["StoreId"]     = lRole.data.StoreId;
                                Session["StoreStatus"] = lRole.data.StoreStatus;
                                Session["LoginID"]     = lRole.data.UserID;
                                Session["Username"]    = lRole.data.FirstName + ' ' + lRole.data.LastName;
                                return(RedirectToAction("Dashboard", "Main"));
                            }
                            else if (lRole.data.StoreId == Convert.ToInt32(login.StoreName))
                            {
                                Session["StoreId"]     = lRole.data.StoreId;
                                Session["StoreStatus"] = lRole.data.StoreStatus;
                                Session["LoginID"]     = lRole.data.UserID;
                                Session["Username"]    = lRole.data.FirstName + ' ' + lRole.data.LastName;
                                return(RedirectToAction("Dashboard", "Main"));
                            }
                            else
                            {
                                ViewBag.Message = "Please Select Store!";
                            }
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        //ModelState.AddModelError("", "Invalid username or password");
                        //return View("Index", login);
                        ViewBag.Message = "Invalid username or password";
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
            else
            {
                ViewBag.Message = "Invalid username or password";
            }

            return(RedirectToAction("Index", "Home"));
        }
        public InstagramUserDataOptimized GetInstagramUserData()
        {
            WebClient      webClient          = new WebClient();
            var            response           = webClient.DownloadString("https://api.instagram.com/v1/users/self/?access_token=" + ConfigurationManager.AppSettings["access_token"]);
            UserRootObject deserializedObject = JsonConvert.DeserializeObject <UserRootObject>(response);

            return(new InstagramUserDataOptimized()
            {
                FollowersCount = deserializedObject.data.counts.followed_by.ToString(),
                PostsCount = deserializedObject.data.counts.media.ToString(),
                ProfileImageUrl = deserializedObject.data.profile_picture,
                Username = deserializedObject.data.username,
                FollowingCount = deserializedObject.data.counts.follows.ToString()
            });
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Userlogin(UserLoginViewModel login, string returnUrl = null)
        {
            if (ModelState.IsValid)
            {
                string url = GetUrl(2);
                url = url + "/WebSiteLogin/WebsiteLogin?username="******"&password="******"";
                UserRootObject lRole = new UserRootObject();
                using (HttpClient client = new HttpClient())
                {
                    HttpResponseMessage responseMessage = await client.GetAsync(url);

                    if (responseMessage.IsSuccessStatusCode)
                    {
                        var result = responseMessage.Content.ReadAsStringAsync().Result;
                        lRole = JsonConvert.DeserializeObject <UserRootObject>(result);
                        if (lRole.response.isSuccess == true)
                        {
                            Session["LoginID"]  = lRole.data.UserID;
                            Session["Username"] = lRole.data.FirstName + ' ' + lRole.data.LastName;
                            return(RedirectToAction("Index", "MenuSetupMaster"));
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid username or password");
                        return(View("Index", login));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "Incorrect username and/or password");
            }
            return(View(login));
        }