Пример #1
0
 public MapDTO GetMap(int hostId)
 {
     return((from h in _hostRepo.Get(hostId)
             select new MapDTO()
     {
         ImageUrl = "/Images/Festmap.png",
         Pins = (from p in h.Pushpins
                 select new PushpinDTO()
         {
             Name = p.Name,
             Left = p.Left,
             Top = p.Top,
             Category = p.Category
         }).ToList()
     }).FirstOrDefault());
 }
Пример #2
0
        public State PushResult(TaskResult result)
        {
            ResultRepository resultRepo = new ResultRepository();
            HostRepository   hostRepo   = new HostRepository();
            TaskRepository   taskRepo   = new TaskRepository();

            if (resultRepo.Get(result.HostId, result.TaskId, result.PartId) != null)
            {
                return(new State()
                {
                    IsError = true, Message = "Result was already pushed!"
                });
            }
            if (hostRepo.Get(result.HostId) == null)
            {
                return(new State()
                {
                    IsError = true, Message = "There is no any host with this id!"
                });
            }
            if (taskRepo.Get(result.HostId, result.TaskId) == null)
            {
                return(new State()
                {
                    IsError = true, Message = "There is no any task with this id for this host!"
                });
            }

            resultRepo.Create(new TaskResultEntity
            {
                HostId = result.HostId,
                TaskId = result.TaskId,
                PartId = result.PartId,
                //Array = result.Data.Array,
                Height   = result.Data.Height,
                Width    = result.Data.Width,
                StepFrom = result.StepFrom,
                StepTo   = result.StepTo
            });
            resultRepo.Save();

            return(new State()
            {
                IsError = false, Message = "Push was succesed complete!"
            });
        }
Пример #3
0
        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!"
            });
        }
Пример #4
0
        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!"
            });
        }
    }
}