示例#1
0
        public string GetCafeTradeName(Location location)
        {
            string tradeName = "Unknown";

            for (int i = 0; i < Cafes.Count(); i++)
            {
                if (Cafes[i].Latitude == location.Latitude && Cafes[i].Longitude == location.Longitude)
                {
                    tradeName = Cafes[i].TradeName;
                    //if null or empty string return 'Unknown'.
                    if (tradeName != null)
                    {
                        if (tradeName != "")
                        {
                            return(tradeName);
                        }
                        else
                        {
                            tradeName = "Unknown"; return(tradeName);
                        }
                    }
                    else
                    {
                        tradeName = "Unknown"; return(tradeName);
                    }
                }
            }
            return(tradeName);
        }
示例#2
0
        /// <summary>
        /// Удалить комментарий.
        /// </summary>
        /// <param name="cafeName"> Название кафе. </param>
        /// <returns>
        /// Возвращает true, если комментарий успешно удален.
        /// Если комментария нет, то возвращает false.
        /// </returns>
        public bool DeleteComment(Cafe cafe)
        {
            #region Проверка
            if (cafe == null)
            {
                throw new ArgumentNullException($"{nameof(cafe)} не может быть null", nameof(cafe));
            }
            if (Cafes.FirstOrDefault(c => c.Name == cafe.Name) == null)
            {
                throw new ArgumentException("Не существует кафе с таким названием", nameof(cafe.Name));
            }
            #endregion

            var comments = GetComments();
            var comment  = comments.SingleOrDefault(c => c.User.Name == CurrentUser.Name && c.CafeName == cafe.Name);
            if (comment == null)
            {
                return(false);
            }
            else
            {
                comments.Remove(comment);
            }
            Save(comments);
            return(true);
        }
示例#3
0
 public void Clear()
 {
     lock (Dwellers) Dwellers.Clear();
     Homes.Clear();
     Cafes.Clear();
     Workplaces.Clear();
 }
示例#4
0
        /// <summary>
        /// Получить кафе с таким названием.
        /// </summary>
        /// <param name="cafeName"> Название кафе. </param>
        /// <returns> Кафе или null, если такого нет. </returns>
        public Cafe GetCafe(string cafeName)
        {
            if (string.IsNullOrWhiteSpace(cafeName))
            {
                throw new ArgumentException($"{nameof(cafeName)} не может быть пустым или содержать только пробел", nameof(cafeName));
            }

            return(Cafes.FirstOrDefault(c => c.Name == cafeName));
        }
示例#5
0
        //private void CheckNewLocation(IDweller dweller, IBuilding obj)
        //{
        //	if (dweller.Position.Value == obj.Position.Value)
        //	{
        //		// yep
        //		dweller.EnterBuilding(obj);
        //	}
        //}

        public void Add(IBuilding building)
        {
            switch (building)
            {
            case IHome home:
                Homes.Add(home);
                break;

            case IWorkplace workplace:
                Workplaces.Add(workplace);
                break;

            case ICafe cafe:
                Cafes.Add(cafe);
                break;
            }
        }
示例#6
0
        public string GetCafeName(Location location)
        {
            string name = "Unknown";

            for (int i = 0; i < Cafes.Count(); i++)
            {
                if (Cafes[i].Latitude == location.Latitude && Cafes[i].Longitude == location.Longitude)
                {
                    name = Cafes[i].Name;
                    if (name != null)
                    {
                        return(name);
                    }
                    else
                    {
                        name = "Unknown"; return(name);
                    }
                }
            }
            return(name);
        }
示例#7
0
        public string GetCafePhone(Location location)
        {
            string phone = "Unknown";

            for (int i = 0; i < Cafes.Count(); i++)
            {
                if (Cafes[i].Latitude == location.Latitude && Cafes[i].Longitude == location.Longitude)
                {
                    phone = Cafes[i].PhoneNumber;
                    if (phone != null)
                    {
                        return(phone);
                    }
                    else
                    {
                        phone = "Unknown"; return(phone);
                    }
                }
            }
            return(phone);
        }
示例#8
0
        /// <summary>
        /// Добавить комментарий.
        /// </summary>
        /// <param name="cafe"> Кафе. </param>
        /// <param name="userComment"> Комментарий. </param>
        public void AddComment(UserComment userComment)
        {
            #region Проверка
            if (userComment == null)
            {
                throw new ArgumentNullException($"{nameof(userComment)} не может быть null", nameof(userComment));
            }
            if (Cafes.FirstOrDefault(c => c.Name == userComment.CafeName) == null)
            {
                throw new ArgumentException("Не существует кафе с таким названием", nameof(userComment.CafeName));
            }
            #endregion

            var comments   = GetComments();
            var oldComment = comments.SingleOrDefault(c => c.User.Name == CurrentUser.Name);
            if (oldComment != null)
            {
                comments.Remove(oldComment);
            }

            comments.Add(userComment);
            Save(comments);
        }
示例#9
0
        //The next few methods Get information from the Cafes and returns them to the InfoBox.

        //this takes the location of the pushpin and compares that with the location of the cafe (longitude, latitude)
        public string GetCafeStreet(Location location)
        {
            string street = "Unknown"; //default value should the for/if fail.

            //loop thought all cafe (not very efficient, could loop through 1 time or 1000 times before/if it finds a match)
            for (int i = 0; i < Cafes.Count(); i++)
            {
                if (Cafes[i].Latitude == location.Latitude && Cafes[i].Longitude == location.Longitude)
                {
                    //if it finds a match then we have found the coresponding cafe.
                    street = Cafes[i].StreetAddress;
                    //if null then return 'Unknown'.
                    if (street != null)
                    {
                        return(street);
                    }
                    else
                    {
                        street = "Unknown"; return(street);
                    }
                }
            }
            return(street);
        }
示例#10
0
        static void MockTestC()
        {
            LinkedList <float> lista = new LinkedList <float>();

            lista.AddFirst(5.2f);
            lista.AddLast(6.0f);
            foreach (var elemento in lista)
            {
                Console.WriteLine("{0}", elemento);
            }

            Console.WriteLine();
            HashSet <int> myHashSet = new HashSet <int>();

            myHashSet.Add(34);
            myHashSet.Add(35);
            myHashSet.Add(36);
            foreach (var itemHash in myHashSet)
            {
                Console.WriteLine("{0}", itemHash);
            }

            Cafes myCafe = Cafes.MEDIANO;

            Console.WriteLine("Cafe: {0}", myCafe);
            if (myCafe == Cafes.MEDIANO)
            {
                Console.WriteLine("Mi cafe es de tamaño mediano");
            }

            switch (myCafe)
            {
            case Cafes.CHICO:
                Console.WriteLine("Este cafe es de tamaño chico"); break;

            case Cafes.MEDIANO:
                Console.WriteLine("Este cafe es de tipo mediano"); break;

            case Cafes.GRANDE:
                Console.WriteLine("Este cafe es de tipo grande"); break;

            case Cafes.JUMBO:
                Console.WriteLine("Este cafe es de tipo jumbo"); break;

            default:
                Console.WriteLine("Ese cafe esta en vias de no existir"); break;
            }

            var programador = Programador.SENIOR;

            switch (programador)
            {
            case "JUNIOR":
                Console.WriteLine("Programador {0}", programador);
                break;

            case "MID_LEVEL":
                Console.WriteLine("Programador {0}", programador);
                break;

            case "SENIOR":
                Console.WriteLine("Programador {0}", programador);
                break;

            case "MASTER":
                Console.WriteLine("Programador {0}", programador);
                break;

            default:
                Console.WriteLine("Programador {0}", programador);
                break;
            }
        }
示例#11
0
        /// <summary>
        /// Add a cafe to the view model.
        /// </summary>
        /// <param name="cafe">The cafe to be added</param>

        public void AddCafeToModel(Cafe cafe)
        {
            Cafes.Add(cafe);
        }