public ActionResult ListFiles()
        {
            CacheRepository cr     = new CacheRepository();
            UsersRepository ur     = new UsersRepository();
            var             result = new List <Models.FileUpload>();

            result = cr.GetFilesFromCache(ur.GetUserID(User.Identity.Name));
            return(View(result));
        }
Пример #2
0
        public ActionResult Index()
        {
            UserRepository ur = new UserRepository();
            FileRepository fr = new FileRepository();

            try
            {
                string email = User.Identity.Name;

                if (email != null || email != "")
                {
                    //check if email exists
                    if (ur.DoesEmailExist(email))
                    {
                        CacheRepository cr          = new CacheRepository();
                        List <File>     cacheResult = cr.GetFilesFromCache(email); //Get files from Cache


                        // If items in db and cache are not the same amount get all data from db.
                        if (fr.GetFiles(email).Count != cacheResult.Count)
                        {
                            cr.UpdateCache(fr.GetFiles(email), email); //get items from db and update cache
                            return(View(cr.GetFilesFromCache(email))); //get files from cache using the updated version.
                        }
                        else
                        {
                            //return from cache if has latest update.
                            return(View(cacheResult));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                new LogRepository().LogError(e);
            }


            return(View());
        }
Пример #3
0
        public ActionResult Index()
        {
            try
            {
                new LoggingRepository().Logging("Getting Items");

                #region get products of db - removed....instead insert next region
                FilesRepository pr = new FilesRepository();
                //var products = pr.GetProducts(); //gets products from db
                #endregion

                #region instead of getting products from DB, to make your application faster , you load them from the cache
                CacheRepository cr = new CacheRepository();
                cr.UpdateCache(pr.GetFiles(User.Identity.Name)); //commented
                var files = cr.GetFilesFromCache();
                #endregion
                return(View("Index", files));
            }
            catch (Exception ex)
            {
                new LoggingRepository().ErrorLogging(ex);
            }
            return(View("Index"));
        }