Beispiel #1
0
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Request.Cookies["token"]))
            {
                TempData["Unauthenticated"] = "Please Log In";
                return(View("Login"));
            }
            int x = Convert.ToInt32(simple.m);


            memberdetailsrepo h = new memberdetailsrepo();

            List <memberdetails> b = new List <memberdetails>();

            b = h.supplymemberdetails();

            foreach (var item in b)
            {
                if (item.memberid == x)
                {
                    ViewBag.Message = item.membername;
                }
            }

            //ViewBag.message = "Dude its very simple";

            // int x = Convert.ToInt32(simple.m);

            List <memberclaim> ls = new List <memberclaim>();

            string token = HttpContext.Request.Cookies["token"];

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/member/" + x).Result;

            if (response.IsSuccessStatusCode)
            {
                string data = response.Content.ReadAsStringAsync().Result;
                ls = JsonConvert.DeserializeObject <List <memberclaim> >(data);
            }

            return(View(ls));
        }
        public IActionResult Index()
        {
            if (string.IsNullOrEmpty(HttpContext.Request.Cookies["token"]))
            {
                TempData["Unauthenticated"] = "Please Log In";
                return(View("Login"));
            }
            int x = Convert.ToInt32(simple.m);


            memberdetailsrepo h = new memberdetailsrepo();

            List <memberdetails> b = new List <memberdetails>();

            b = h.supplymemberdetails();

            foreach (var item in b)
            {
                if (item.memberid == x)
                {
                    ViewBag.Message = item.membername;
                }
            }

            //ViewBag.message = "Dude its very simple";

            // int x = Convert.ToInt32(simple.m);
            int f = 0;

            List <memberclaim> ls = new List <memberclaim>();

            string token = HttpContext.Request.Cookies["token"];

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

            HttpResponseMessage response = client.GetAsync(client.BaseAddress + "/member/" + x).Result;

            if (response.IsSuccessStatusCode)
            {
                string data = response.Content.ReadAsStringAsync().Result;
                ls = JsonConvert.DeserializeObject <List <memberclaim> >(data);
                foreach (var item in ls)
                {
                    foreach (var item1 in _con.claimsubmits)
                    {
                        if (item.claimid == item1.claimid)//this check will happen only once
                        {
                            item1.claimstatus = item.claimstatus;
                            f = 1;
                        }
                    }
                    if (f == 0)
                    {
                        claimsubmit obk = new claimsubmit();
                        obk.claimid     = item.claimid;
                        obk.claimstatus = item.claimstatus;
                        _con.claimsubmits.Add(obk);
                    }
                    f = 0;
                }
                _con.SaveChanges(); // The changes are made in the database atlast
            }
            return(View(ls));
        }