示例#1
0
        public PartialVM GetHeader()
        {
            using (var db = new ProjectWebEntities())
            {
                var model = new PartialVM();
                model.AboutUs = db.Tbl_AboutUs.Find(1);
                var menu   = GetMenuTree(1);
                var result = new List <MenuIndex>();
                foreach (var m in menu)
                {
                    var tmp = new MenuIndex();

                    tmp.MenuId     = m.MenuId;
                    tmp.MenuCode   = m.MenuCode;
                    tmp.Menu       = m.Menu;
                    tmp.ProductId  = m.ProductId;
                    tmp.ParentId   = m.ParentId;
                    tmp.NewsId     = m.NewsId;
                    tmp.NewsTypeId = m.NewsTypeId;
                    tmp.Children   = m.Children;
                    tmp.Url        = m.Url;

                    result.Add(tmp);
                }
                model.ListMenuMultiLevels = result;
                return(model);
            }
        }
示例#2
0
        public PartialVM ErrorCheck(string errorMessage)
        {
            PartialVM vm = new PartialVM()
            {
                PartialView = "<h2>" + errorMessage + "</h2>"
            };

            return(vm);
        }
示例#3
0
 public PartialVM GetFooter()
 {
     using (var db = new ProjectWebEntities())
     {
         var model = new PartialVM();
         model.ListFooter = db.Tbl_Footer.Where(p => p.IsDisable == false).ToList();
         model.AboutUs    = db.Tbl_AboutUs.Find(1);
         return(model);
     }
 }
        public IActionResult Register()
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(accountServiceLink, "/Account/Register", cookievalue, "Register Service Down", _handler);

            return(View(vm));
        }
        public IActionResult Index()
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(cartServiceLink, "api/CustomerOrdering/View/Cart", cookievalue, "Cart Service Down", _handler);

            return(View(vm));
        }
示例#6
0
        public ActionResult Edit(string id)
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(profileServiceLink, "/User/Edit/" + id, cookievalue, "User Service Down", _handler);

            return(View(vm));
        }
        public IActionResult Details(int id)
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["token"] != null)
            {
                cookievalue = Request.Cookies["token"].ToString();
            }

            PartialVM vm = client.GetClient(messageServiceLink, "/MessagesMVC/details/" + id, cookievalue, "", _handler);

            return(View(vm));
        }
        // GET: Messages/Send/1
        public IActionResult Send(string id)
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(messageServiceLink, "/MessagesMVC/send/" + id, cookievalue, "Messaging Service Down", _handler);

            return(View(vm));
        }
示例#9
0
        public IActionResult InvoicesDetails(string reference)
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(invoiceServiceLink, "/api/Invoice/Views/InvoiceDetails/" + reference, cookievalue, "Invoice Service Down", _handler);

            return(View(vm));
        }
示例#10
0
        public IActionResult ProductDetails(string EAN)
        {
            Client client = new Client();

            //Read cookie
            string cookievalue = "";

            if (Request.Cookies["access_token"] != null)
            {
                cookievalue = Request.Cookies["access_token"].ToString();
            }

            PartialVM vm = client.GetClient(productServiceLink, "api/Product/Views/ProductDetails?EAN=" + EAN, cookievalue, "Product Details Not Found", _handler);

            return(View(vm));
        }
示例#11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="baseLink">Base URL</param>
        /// <param name="path">Sub path of URL</param>
        /// <param name="token">token being passed by services</param>
        /// <param name="errorMessage">error message to display if current service is down</param>
        /// <param name="handler">handler used only for testing purposes</param>
        /// <returns></returns>
        public PartialVM GetClient(string baseLink, string path, string token, string errorMessage, HttpMessageHandler handler)
        {
            using (HttpClient client = new HttpClient(handler, false))
            {
                try
                {
                    client.BaseAddress = new Uri(baseLink);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
                    if (token != "")
                    {
                        client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                    }

                    HttpResponseMessage response = client.GetAsync(path).Result;

                    if (response.IsSuccessStatusCode)
                    {
                        PartialVM vm = new PartialVM();
                        vm.PartialView = response.Content.ReadAsStringAsync().Result;
                        response.Dispose();

                        return(vm);
                    }
                    else
                    {
                        return(new PartialVM()
                        {
                            PartialView = "<h2>" + errorMessage + "</h2>"
                        });
                    }
                }
                catch (Exception e)
                {
                    return(new PartialVM()
                    {
                        PartialView = "<h2> Error </h2> <div>" + errorMessage + "</div> <div>" + e.Message + "</div>"
                    });
                }
            }
        }