public ActionResult BuildLaptop(FormCollection collection) { Employee employee = db.Employees.Find(Convert.ToInt32(collection["Id"])); ISystemBuilder systemBuilder = new LaptopBuilder(); Director.ConfigurationBuilder configurationBuilder = new Director.ConfigurationBuilder(); configurationBuilder.BuildSystem(systemBuilder, collection); ComputerSystem computerSystem = systemBuilder.GetSystem(); employee.SystemConfigurationDetails = string.Format("RAM: {0},HDDSize: {1},TouchScreen: {2}", computerSystem.RAM, computerSystem.HDDSize, computerSystem.TouchScreen); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult BuildLaptop(FormCollection formCollection) { //step 1 Employee employee = db.Employees.Find(Convert.ToInt32(formCollection["employeeID"])); //step 2 concrete builder ISystemBuilder systemBuilder = new LaptopBuilder(); //step 3 Director ConfigurationBuilder builder = new ConfigurationBuilder(); builder.BuildSystem(systemBuilder, formCollection); //step 4 return the system ComputerSystem system = systemBuilder.GetSystem(); employee.SystemConfigurationDetails = string.Format("RAM:{0},HDDSize:{1},TouchScreen:{2}" , system.RAM, system.HDDSize, system.TouchScreen); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }