Esempio n. 1
0
        private Dictionary <string, Project> Get()
        {
            Dictionary <string, Project> projects = _fileStore.Get();

            if (projects == null)
            {
                projects = new Dictionary <string, Project>();
            }

            return(projects);
        }
Esempio n. 2
0
        public async Task <IActionResult> Get(Guid id, int fileNo)
        {
            var a = await _aContext.A.FindAsync(id);

            if (a == null)
            {
                return(NotFound($"Object A with Id = {id} not found."));
            }

            Stream stream = null;

            try
            {
                switch (fileNo)
                {
                case 1: stream = _fileStore.Get(a.File1, FileMode.Open, FileAccess.Read); break;

                case 2: stream = _fileStore.Get(a.File2, FileMode.Open, FileAccess.Read); break;

                case 3: stream = _fileStore.Get(a.File3, FileMode.Open, FileAccess.Read); break;

                default: ModelState.AddModelError("fileNo", "FileNo must be between 1 and 3."); break;
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(NotFound($"File{fileNo} of object A with Id = {id} cannot be opened"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(new FileStreamResult(stream, "image/jpeg"));
        }
Esempio n. 3
0
        protected override void RenderMenuItems(MenuLine[] menuPrint)
        {
            FileStore store = _fileStoreOperator.Store;

            menuPrint[2]  = CenterAlign(WithColor("HIGHSCORE", Color.PURPLE));
            menuPrint[4]  = CenterAlign($"1. {store.Get("h1_name")}: {store.Get("h1_value")}");
            menuPrint[5]  = CenterAlign($"2. {store.Get("h2_name")}: {store.Get("h2_value")}");
            menuPrint[6]  = CenterAlign($"3. {store.Get("h3_name")}: {store.Get("h3_value")}");
            menuPrint[7]  = CenterAlign($"4. {store.Get("h4_name")}: {store.Get("h4_value")}");
            menuPrint[8]  = CenterAlign($"5. {store.Get("h5_name")}: {store.Get("h5_value")}");
            menuPrint[9]  = CenterAlign($"6. {store.Get("h6_name")}: {store.Get("h6_value")}");
            menuPrint[10] = CenterAlign($"7. {store.Get("h7_name")}: {store.Get("h7_value")}");
            menuPrint[11] = CenterAlign($"8. {store.Get("h8_name")}: {store.Get("h8_value")}");
            menuPrint[12] = CenterAlign($"9. {store.Get("h9_name")}: {store.Get("h9_value")}");
            menuPrint[13] = CenterAlign($"10. {store.Get("h10_name")}: {store.Get("h10_value")}");

            string back = $"{HighlightableString("back", "Back", Color.RED)}";

            menuPrint[18] = CenterAlign(back);
        }