示例#1
0
        private static void AddImageToUser()
        {
            System.Console.Write("Enter image's description: ");
            string description = System.Console.ReadLine();


            if (string.IsNullOrWhiteSpace(description))
            {
                System.Console.WriteLine("Incorrect input");
            }
            else
            {
                if (imagesBLL.AddImage(new ImageVM(description)))
                {
                    System.Console.WriteLine("Successfully added");
                }
                else
                {
                    System.Console.WriteLine("Such award already exists");
                }
            }

            var users      = usersBLL.GetAllUsers().OrderBy(user => user.LastName);
            int numberUser = GetSelectedNumberOfUser(users);

            if (numberUser != 0)
            {
                var user        = users.Skip(numberUser - 1).First();
                var images      = imagesBLL.GetAllImages().OrderBy(image => image.DateOfCreating);
                int numberImage = GetSelectedNumberOfImage(images);
                if (numberImage != 0)
                {
                    var image = images.Skip(numberImage - 1).First();
                    if (relationsBLL.AddImageToUser(user.Id, image.Id))
                    {
                        System.Console.WriteLine("Image successfully added to user");
                    }
                    else
                    {
                        System.Console.WriteLine("User already have this award");
                    }
                    System.Console.ReadLine();
                }
            }
        }
示例#2
0
 internal static bool Create(ImageVM image)
 {
     return(imagesLogic.AddImage(image));
 }