Ejemplo n.º 1
0
 private VisEdge BuildRootLink(TechArea area, string to)
 {
     return(new VisEdge()
     {
         @from = BuildRootNodeName(area),
         to = to,
         color = new VisColor()
         {
             opacity = 0
         }
     });
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("TechAreaId,Name,Description,Image")] TechArea techArea, IFormFile ImageFile)
        {
            if (id != techArea.TechAreaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                if (ImageFile != null)
                {
                    var FileName      = Path.GetRandomFileName() + Path.GetExtension(ImageFile.FileName);
                    var FileDirectory = "wwwroot/images/techarea";

                    if (!Directory.Exists(FileDirectory))
                    {
                        Directory.CreateDirectory(FileDirectory);
                    }

                    var FilePath = FileDirectory + "/" + FileName;

                    using (var Stream = new FileStream(FilePath, FileMode.Create))
                    {
                        await ImageFile.CopyToAsync(Stream);
                    }

                    techArea.Image = FileName;
                }

                try
                {
                    _context.Update(techArea);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TechAreaExists(techArea.TechAreaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(techArea));
        }
Ejemplo n.º 3
0
        private VisNode BuildRootNode(TechArea area, string imagesPath)
        {
            var relativePath = CreateRelativePath(imagesPath);
            var areaName     = area.ToString();
            var result       = new VisNode {
                id       = BuildRootNodeName(area),
                label    = localisationApi.GetName(areaName.ToLower()),
                group    = areaName,
                image    = relativePath + "/" + BuildRootNodeName(area) + ".png",
                hasImage = true,
                level    = 0,
                nodeType = "tech"
            };

            return(result);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("TechAreaId,Name,Description,Image")] TechArea techArea, IFormFile ImageFile)
        {
            if (ModelState.IsValid)
            {
                if (ImageFile != null)
                {
                    var FileName      = Path.GetRandomFileName() + Path.GetExtension(ImageFile.FileName);
                    var FileDirectory = "wwwroot/images/techarea";

                    if (!Directory.Exists(FileDirectory))
                    {
                        Directory.CreateDirectory(FileDirectory);
                    }

                    var FilePath = FileDirectory + "/" + FileName;

                    using (var Stream = new FileStream(FilePath, FileMode.Create))
                    {
                        await ImageFile.CopyToAsync(Stream);
                    }

                    techArea.Image = FileName;
                }
                else
                {
                    techArea.Image = "def.jpg";
                }


                _context.Add(techArea);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(techArea));
        }
Ejemplo n.º 5
0
 private static string BuildRootNodeName(TechArea techArea)
 {
     return(techArea + "-root");
 }