Exemple #1
0
        public State RegisterHost(Host host)
        {
            //bool exist = false;

            HostRepository hostRepo = new HostRepository();
            //var hosts = hostRepo.GetAll();

            //foreach(var h in hosts)
            //{
            //    if (h.Ip == host.Ip && h.Port == host.Port)
            //    {
            //        exist = true;
            //    }
            //}

            //if (exist)
            //{
            //    return new State() {IsError = true, Message = "Host is already registred!" };
            //}

            //string id = Guid.NewGuid().ToString();
            HostEntity entity = new HostEntity {
                HostId = host.Id, Ip = host.Ip, Port = host.Port, IsBusy = host.IsBusy
            };

            hostRepo.Create(entity);
            //hostRepo.Save();

            return(new State()
            {
                IsError = false, Message = "id"
            });
        }