public async Task <IActionResult> Create(CreateComponentTypeViewModel componentTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                //Make image
                byte[] image;
                byte[] thumbnail;
                using (var m = new MemoryStream())
                {
                    await componentTypeViewModel.ImageUpload.CopyToAsync(m);

                    image = m.ToArray();
                }
                //Make thumbnail
                using (var m = new MemoryStream())
                {
                    await componentTypeViewModel.ImageUpload.CopyToAsync(m);

                    using (var ti = new FreeImageBitmap(componentTypeViewModel.ImageUpload.OpenReadStream()))
                    {
                        var thumb = ti.GetThumbnailImage(100, true);
                        using (var nm = new MemoryStream())
                        {
                            thumb.Save(nm, Util.Util.FindImageFormat(componentTypeViewModel.ImageUpload.ContentType));
                            thumbnail = nm.ToArray();
                        }
                    }
                }
                var componentType = new ComponentType
                {
                    ComponentName = componentTypeViewModel.ComponentName,
                    AdminComment  = componentTypeViewModel.AdminComment,
                    ComponentInfo = componentTypeViewModel.ComponentInfo,
                    Datasheet     = componentTypeViewModel.Datasheet,
                    Location      = componentTypeViewModel.Location,
                    WikiLink      = componentTypeViewModel.WikiLink,
                    Manufacturer  = componentTypeViewModel.Manufacturer,
                    Image         = new EsImage
                    {
                        ImageData     = image,
                        Thumbnail     = thumbnail,
                        ImageMimeType = componentTypeViewModel.ImageUpload.ContentType
                    }
                };
                var category = await _context.Categories.FirstOrDefaultAsync(c => c.CategoryId == componentTypeViewModel.Category);

                if (category != null)
                {
                    _context.Add(componentType);
                    await _context.SaveChangesAsync();

                    _context.Add(new ComponentTypeCategory {
                        Category = category, ComponentType = componentType
                    });
                    await _context.SaveChangesAsync();
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(componentTypeViewModel));
        }