public ActionResult CreateContainer(int id) { WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement(); UpdateInProgressMessage(id, "Creating Worker Container"); AsynchronousCallback ContainerThread = new AsynchronousCallback(workerContainersManagement.CreateWorker); ContainerThread.BeginInvoke(id, null, null); return RedirectToAction("CloudDetails", "CloudManagement", new { id = new WorkerContainersManagement().cloudLookupFromWorkerId(id).CloudId }); }
public ActionResult EditPost(Worker worker, bool isQuarantined, int? CloudID, int?[] ServicesList) { if (!CloudID.HasValue) ModelState.AddModelError(String.Empty, "Please choose a cloud"); if (ModelState.IsValid) { db.Entry(worker).State = EntityState.Modified; db.SaveChanges(); //Link To Cloud var CloudList = db.Clouds.ToList(); for (int CloudIndex = 0; CloudIndex < CloudList.Count(); CloudIndex++) if (CloudList[CloudIndex].Workers.Where(x => x.WorkerId == worker.WorkerId).Count() > 0) db.Clouds.ToList()[CloudIndex].Workers.Remove(worker); db.SaveChanges(); if (CloudID.HasValue) { db.Clouds.Find(CloudID).Workers.Add(worker); db.SaveChanges(); } //Services List var worker2 = db.Workers.Include(x => x.Services).Where(x => x.WorkerId == worker.WorkerId).First(); if (worker2.Services == null) worker2.Services = new List<Service>(); foreach (var service in db.Services.ToList()) worker2.Services.Remove(service); db.SaveChanges(); if (ServicesList != null) { foreach (int serviceID in ServicesList) { var service = db.Services.Find(serviceID); worker2.Services.Add(service); } db.SaveChanges(); } WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement(); workerContainersManagement.RefreshWorker(worker2.WorkerId); return RedirectToAction("Dashboard", "Home"); } return View("~/Views/Home/Dashboard.cshtml", worker); }
public ActionResult RefreshAllWorkers(int id) { WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement(); workerContainersManagement.RefreshAllWorkers(id); return RedirectToAction("CloudDetails", "CloudManagement", new { id = id }); }
public ActionResult Details(int id) { //Get the Worker entity from the database using the given ID WorkerContainersManagement workerContainersManagement = new WorkerContainersManagement(); //Get and pass to the view the machine that has this worker Worker worker = db.Workers.Find(id); Cloud cloud = workerContainersManagement.cloudLookupFromWorkerId(id); ViewBag.Machine = workerContainersManagement.machineLookupFromMasterId(cloud.Master.MasterId); //Pass this entity to the view return PartialView(worker); }