public IActionResult UpdateComponentType(ComponentType model)
        {
            BackEnd.Models.ComponentType component = new BackEnd.Models.ComponentType();
            component.ComponentTypeId = model.ComponentTypeId;
            ComponentTypeHandler handler = new ComponentTypeHandler(new bachelordbContext());
            var newcat = handler.getComponentType(component);

            if (newcat.ComponentName != null)
            {
                newcat.AdminComment  = model.AdminComment;
                newcat.ComponentInfo = model.ComponentInfo;
                newcat.ComponentName = model.ComponentName;
                //dbcat.ComponentTypeStatus
                newcat.Datasheet           = model.Datasheet;
                newcat.ImageUrl            = model.ImageUrl;
                newcat.Location            = model.Location;
                newcat.Manufacturer        = model.Manufacturer;
                newcat.WikiLink            = model.WikiLink;
                newcat.ComponentTypeStatus = model.Status.ToString();

                handler.UpdateComponentType(newcat);

                return(RedirectToAction("Index", "HomePage"));
            }
            else
            {
                this.ModelState.AddModelError("AdminComment", "There is no component with that ID");
                return(View("ViewUpdateComponentType"));
            }
        }
        public IActionResult CreateComponentType(ComponentType model)
        {
            ComponentTypeHandler handler = new ComponentTypeHandler(new bachelordbContext());

            BackEnd.Models.ComponentType dbcat = new BackEnd.Models.ComponentType();
            dbcat.AdminComment  = model.AdminComment;
            dbcat.ComponentInfo = model.ComponentInfo;
            dbcat.ComponentName = model.ComponentName;
            //dbcat.ComponentTypeStatus
            dbcat.Datasheet           = model.Datasheet;
            dbcat.ImageUrl            = model.ImageUrl;
            dbcat.Location            = model.Location;
            dbcat.Manufacturer        = model.Manufacturer;
            dbcat.WikiLink            = model.WikiLink;
            dbcat.ComponentTypeStatus = model.Status.ToString();
            if (model.selectedCat2 == "Emptyval")
            {
                handler.saveComponentType(dbcat, Int32.Parse(model.selectedCat));
            }
            else if (model.selectedCat == "Emptyval" && model.selectedCat2 == "Emptyval")
            {
            }
            else
            {
                handler.saveComponentType(dbcat, Int32.Parse(model.selectedCat), Int32.Parse(model.selectedCat2));
            }


            return(RedirectToAction("Index", "HomePage"));
        }
        public IActionResult DeleteComponentType(ComponentType model)
        {
            BackEnd.Models.ComponentType component = new BackEnd.Models.ComponentType();
            component.ComponentTypeId = model.ComponentTypeId;
            ComponentTypeHandler handler = new ComponentTypeHandler(new bachelordbContext());

            handler.DeleteComponentType(component);
            return(RedirectToAction("Index", "HomePage"));
        }