public State SaveTask(Task task) { HostRepository hostRepo = new HostRepository(); TaskRepository taskRepo = new TaskRepository(); var host = hostRepo.Get(task.HostId); if (host == null) { return new State { IsError = true, Message = "There is no any host with this id!" } } ; if (host.IsBusy) { return new State { IsError = true, Message = "This host is already busy!" } } ; taskRepo.Create(new TaskEntity { HostId = task.HostId, TaskId = task.TaskId, //Array = task.Data.Array, Height = task.Data.Height, Width = task.Data.Width, StepsCount = task.StepsCount }); taskRepo.Save(); host.IsBusy = !(host.IsBusy); hostRepo.Update(host); hostRepo.Save(); return(new State { IsError = false, Message = "Task was saved succesfully!" }); } } }
public State UnRegisterHost(string id) { HostRepository hostRepo = new HostRepository(); var host = hostRepo.Get(id); if (host != null) { hostRepo.Delete(id); hostRepo.Save(); return(new State() { IsError = false, Message = "Host is disconnected!" }); } return(new State() { IsError = true, Message = "There is no any host with this id!" }); }
public void AddHost(Host host) { host = m_HostRepo.Save(host); SaveHostTag(host); }