Exemple #1
0
        // GET: Shop
        public async Task <ActionResult> Index()
        {
            if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
            {
                LocalStorageExtensions.Clear();
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
            }

            try
            {
                PaginationViewModel paginationViewModel = new PaginationViewModel()
                {
                    userId   = LocalStorageExtensions.Get(StorageType.UserId),
                    pageId   = 1,
                    pageSize = -1,
                };
                string response = await APICallerExtensions.APICallAsync("Shop/GetAll", paginationViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }
                ShopViewModel shopViewModel = new ShopViewModel();
                var           content       = JsonConvert.DeserializeObject <SingleResponse <List <Shop> > >(response);
                if (!content.DidError)
                {
                    shopViewModel.listShops = content.Model;

                    PaginationViewModel paginationViewModel2 = new PaginationViewModel()
                    {
                        pageId   = 1,
                        pageSize = -1,
                    };
                    string response2 = await APICallerExtensions.APICallAsync("Company/GetAll", paginationViewModel2, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                    if (response.ToLower().Contains("exception:"))
                    {
                        ModelState.AddModelError(string.Empty, response2);
                    }
                    var content2 = JsonConvert.DeserializeObject <SingleResponse <List <Company> > >(response2);
                    if (!content.DidError)
                    {
                        shopViewModel.listCompanies = content2.Model;
                    }

                    return(View(shopViewModel));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View());
            }
        }
 // GET: Dashboard
 public ActionResult Index()
 {
     if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
     {
         LocalStorageExtensions.Clear();
         return(RedirectToAction(nameof(AccountController.Login), "Account"));
     }
     return(View());
 }
        // GET: Profile
        public async Task <ActionResult> Index()
        {
            try
            {
                if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
                {
                    LocalStorageExtensions.Clear();
                    return(RedirectToAction(nameof(AccountController.Login), "Account"));
                }

                string userId = LocalStorageExtensions.Get(StorageType.UserId).ToString();// HttpContext.Session.GetObject(StorageType.UserId).ToString();

                ProfileViewModel profileViewModel = new ProfileViewModel();

                profileViewModel.UserId = userId;
                string response = await APICallerExtensions.APICallAsync("Profile/Get", profileViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }
                var content = JsonConvert.DeserializeObject <SingleResponse <ProfileViewModel> >(response);
                if (!content.DidError)
                {
                    if (string.IsNullOrEmpty(content.Model.Picture))
                    {
                        if (_hostingEnvironment.IsDevelopment())
                        {
                            content.Model.Picture = "/app-assets/images/user.png";
                        }
                        else
                        {
                            content.Model.Picture = "../app-assets/images/user.png";
                        }
                    }

                    return(View(content.Model));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View());
            }
        }
Exemple #4
0
        // GET: Template
        public async Task <ActionResult> Index()
        {
            if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
            {
                LocalStorageExtensions.Clear();
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
            }

            TemplateViewModel templateViewModel = new TemplateViewModel();

            templateViewModel.listTemplate = new List <EmailTemplate>();

            try
            {
                PaginationViewModel paginationViewModel = new PaginationViewModel()
                {
                    pageId   = 1,
                    pageSize = -1,
                };
                string response = await APICallerExtensions.APICallAsync("Template/GetAll", paginationViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }

                var content = JsonConvert.DeserializeObject <SingleResponse <List <EmailTemplate> > >(response);
                if (!content.DidError)
                {
                    templateViewModel.listTemplate = content.Model;
                    return(View(templateViewModel));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View(templateViewModel));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(templateViewModel));
            }
        }
Exemple #5
0
        // GET: Sale
        public async Task <ActionResult> Index()
        {
            if (!LocalStorageExtensions.ValidSession(ControllerContext.ActionDescriptor.ControllerName))
            {
                LocalStorageExtensions.Clear();
                return(RedirectToAction(nameof(AccountController.Login), "Account"));
            }
            SaleViewModel saleViewModel = new SaleViewModel();

            try
            {
                saleViewModel.UserId   = LocalStorageExtensions.Get(StorageType.UserId);
                saleViewModel.pageId   = 1;
                saleViewModel.pageSize = -1;
                string response = await APICallerExtensions.APICallAsync("Sale/GetCardsByUserId", saleViewModel, false, HttpContext.Session.GetObject(StorageType.Token).ToString());

                if (response.ToLower().Contains("exception:"))
                {
                    ModelState.AddModelError(string.Empty, response);
                    return(View());
                }

                var content = JsonConvert.DeserializeObject <SingleResponse <SaleViewModel> >(response);
                if (!content.DidError)
                {
                    saleViewModel = content.Model;
                    return(View(saleViewModel));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, content.Message);
                    return(View(saleViewModel));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(View(saleViewModel));
            }
        }