public ActionResult Create(PSUCreate psu) { var service = new PSUService(); if (ModelState.IsValid) { service.CreatePSU(psu); return(RedirectToAction("Index")); } return(View(psu)); }
//Create public bool CreatePSU(PSUCreate model) { PowerSupplyUnit entity = new PowerSupplyUnit { Name = model.Name, Manufacturer = model.Manufacturer, EffeciencyRating = model.EffeciencyRating, Type = model.Type, TypeOfModular = model.TypeOfModular, Color = model.Color, Fanless = model.Fanless, ATXConnectors = model.ATXConnectors, IsAvailable = model.IsAvailable }; _db.PowerSupplyUnits.Add(entity); return(_db.SaveChanges() == 1); }