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"));
        }
Esempio n. 4
0
        public IActionResult Participant()
        {
            ComponentHandler     comphanlder     = new ComponentHandler(new bachelordbContext());
            ComponentTypeHandler comptypehanlder = new ComponentTypeHandler(new bachelordbContext());
            CategoryHandler      category        = new CategoryHandler(new bachelordbContext());
            HomePageModel        model           = new HomePageModel();

            model.listcategory       = category.getAllCategory();
            model.listcomponenttypes = comptypehanlder.GetAlleComponentTypes();
            model.listcomponent      = comphanlder.getallComponent();
            model.CategoryComponent  = category.GetallCategoryComponentTypes();
            return(View(model));
        }
Esempio n. 5
0
        public IActionResult ViewCreateComponent()
        {
            ComponentTypeHandler comphanlder = new ComponentTypeHandler(new bachelordbContext());
            var list  = comphanlder.GetAlleComponentTypes();
            var model = new Component();

            model.ComponentTypeslist = new List <SelectListItem>();
            foreach (var x in list)
            {
                model.ComponentTypeslist.Add(new SelectListItem
                {
                    Text  = x.ComponentName,
                    Value = x.ComponentTypeId.ToString()
                });
            }
            return(View(model));
        }