Beispiel #1
0
        public void Create(CreateCardDTO createCardDto)
        {
            var createCard = _mapper.Map <CreateCard>(createCardDto);

            _unitOfWork.CreateCardRepository.Create(createCard);
            _unitOfWork.Commit();
        }
Beispiel #2
0
        public BasicCardDTO InsertCard(string username, CreateCardDTO dto)
        {
            //if (!PermissionHelper.HasPermissionOnList(dto.ListId, userId))
            //{
            //    return 0;
            //}

            BasicCardDTO cardDto = null;

            using (UnitOfWork uw = new UnitOfWork())
            {
                CardList list = uw.CardListRepository.GetById(dto.ListId);
                User     user = uw.UserRepository.GetUserByUsername(username);

                Card card = CreateCardDTO.FromDTO(dto);

                if (user != null && list != null)
                {
                    card.User = user;
                    card.List = list;
                    uw.CardRepository.Insert(card);
                    if (uw.Save())
                    {
                        cardDto = new BasicCardDTO(card);
                        RabbitMQService.PublishToExchange(list.Board.ExchangeName,
                                                          new MessageContext(new CardMessageStrategy(cardDto, MessageType.Create, username)));

                        BoardNotificationService.ChangeBoardNotifications(list.Board.BoardId);
                    }
                }
            }
            return(cardDto);
        }
Beispiel #3
0
        public static async Task <BasicCardDTO> CreateCard(string accessToken, CreateCardDTO createCardDTO)
        {
            using (HttpClient client = new HttpClient())
            {
                try
                {
                    string json        = JsonConvert.SerializeObject(createCardDTO);
                    var    buffer      = System.Text.Encoding.UTF8.GetBytes(json);
                    var    byteContent = new ByteArrayContent(buffer);
                    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    client.DefaultRequestHeaders.Add("Authorization", accessToken);
                    var response = await client.PostAsync("http://localhost:52816/api/Card/", byteContent);

                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        var jsonString = await response.Content.ReadAsStringAsync();

                        var card = JsonConvert.DeserializeObject <BasicCardDTO>(jsonString);
                        return(card);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    return(null);
                }
            }
        }
Beispiel #4
0
        public void Remove(CreateCardDTO createCardDto)
        {
            var createCard = _unitOfWork.CreateCardRepository.GetById(createCardDto.CreateCardId);

            _mapper.Map(createCardDto, createCard);
            _unitOfWork.CreateCardRepository.Remove(createCard);
            _unitOfWork.Commit();
        }
        public static async Task PostCard(CreateCardDTO createData, int userId)
        {
            using (HttpClient client = new HttpClient())
            {
                string json = JsonConvert.SerializeObject(createData);

                var buffer = System.Text.Encoding.UTF8.GetBytes(json);

                var byteContent = new ByteArrayContent(buffer);

                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var response = await client.PostAsync($"http://localhost:52816/api/Card/{userId}", byteContent);
            }
        }
Beispiel #6
0
        private async void createCardTextBox_Click(object sender, EventArgs e)
        {
            string   name        = cardNameTextBox.Text;
            string   description = cardDescTextBox.Text;
            DateTime dueDate     = cardDueDatePicker.Value;
            string   listId      = cardParentIdTextBox.Text;

            int userId = int.Parse(userIdTextBox.Text);


            CreateCardDTO createData = new CreateCardDTO()
            {
                Name        = name,
                Description = description,
                ListId      = int.Parse(listId),
                UserId      = userId,
                DueDate     = dueDate
            };

            await CardService.PostCard(createData, userId);
        }
        private void save_btn_Click(object sender, EventArgs e)
        {
            if (card_lstvw.SelectedItems.Count > 0)
            {
                CreateCardDTO createCard = new CreateCardDTO();
                var           dialog     = MessageBox.Show("Are you sure?", "Update", MessageBoxButtons.YesNo);

                if (dialog == DialogResult.Yes)
                {
                    if (cardname_txtbx.Text != "" && cardnumber_txtbx.Text != "" && cvv_lbl.Text != "" && expiredate_dttmpckr.Value != null)
                    {
                        int a;
                        createCard            = _createCardService.GetById(Convert.ToInt32(card_lstvw.SelectedItems[0].SubItems[4].Text));
                        createCard.CardName   = cardname_txtbx.Text;
                        createCard.CardNumber = cardnumber_txtbx.Text;
                        createCard.ExpireDate = expiredate_dttmpckr.Value;
                        if (int.TryParse(cvv_txtbx.Text, out a))
                        {
                            createCard.Cvv = a;
                        }
                        else
                        {
                            createCard.Cvv = null;
                        }
                        createCard.UserId = _user.UserId;
                        _createCardService.Update(createCard);
                    }
                    else
                    {
                        MessageBox.Show("Fields can`t be empty");
                    }
                }
                LoadCardListView();
            }
            else
            {
                MessageBox.Show("Choose user");
            }
        }
        private void new_btn_Click(object sender, EventArgs e)
        {
            CreateCardDTO createCardDTO = new CreateCardDTO();

            if (cardname_txtbx.Text != "" && cardnumber_txtbx.Text != "" && cvv_lbl.Text != "" && expiredate_dttmpckr.Value != null)
            {
                int a;
                createCardDTO.CardName   = cardname_txtbx.Text;
                createCardDTO.CardNumber = cardnumber_txtbx.Text;
                createCardDTO.ExpireDate = expiredate_dttmpckr.Value;
                if (int.TryParse(cvv_txtbx.Text, out a))
                {
                    createCardDTO.Cvv = a;
                }
                else
                {
                    createCardDTO.Cvv = null;
                }
                createCardDTO.UserId = _user.UserId;

                try
                {
                    _createCardService.Create(createCardDTO);
                    MessageBox.Show("Successfully created.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Fields can`t be empty");
            }
            LoadCardListView();
        }
Beispiel #9
0
        public void Start()
        {
            int  i;
            bool Continue = true;

            while (Continue)
            {
                Console.Clear();
                Console.WriteLine("1 - Select user table");
                Console.WriteLine("2 - Select address table");
                Console.WriteLine("3 - Select role table");
                Console.WriteLine("4 - Select create card table");
                Console.WriteLine("9 - Exit");
                i = Convert.ToInt32(Console.ReadLine());

                bool cont = true;
                int  j;

                int Id;
                switch (i)
                {
                case 1:


                    UserService userService = DependencyInjectorUnityBLL.Resolve <UserService>();

                    UserDTO user = new UserDTO();

                    while (cont)
                    {
                        Console.Clear();
                        Console.WriteLine("Selected User Table");
                        Console.WriteLine("1 - Show all users");
                        Console.WriteLine("2 - Select user");
                        Console.WriteLine("3 - Update user");
                        Console.WriteLine("4 - Delete user");
                        Console.WriteLine("5 - Create user");
                        Console.WriteLine("9 - Exit");
                        j = Convert.ToInt32(Console.ReadLine());
                        switch (j)
                        {
                        case 1:
                            Console.Clear();
                            Console.WriteLine("All Users\n");
                            IEnumerable <UserDTO> users = userService.GetAll();
                            foreach (var u in users)
                            {
                                Console.WriteLine($"Id: {u.UserId}\nFirst name: {u.FirstName}\nLast name: {u.LastName}\nEmail: {u.Email}\nLogin: {u.Login}\n\n");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 2:
                            Console.Clear();
                            Console.WriteLine("Select User\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            user = userService.GetById(Id);
                            if (user != null)
                            {
                                Console.WriteLine($"Id: {user.UserId}\nFirst name: {user.FirstName}\nLast name: {user.LastName}\nEmail: {user.Email}\nLogin: {user.Login}\n\n");
                            }
                            else
                            {
                                Console.WriteLine("User doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 3:
                            Console.Clear();
                            Console.WriteLine("Select User for updating\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            user = userService.GetById(Id);
                            string s = "";
                            if (user != null)
                            {
                                Console.WriteLine($"Id: {user.UserId}\nFirst name: {user.FirstName}\nLast name: {user.LastName}\nEmail: {user.Email}\nLogin: {user.Login}\n\n");
                                Console.WriteLine("First name: ");
                                s = "";

                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    user.FirstName = s;
                                    s = "";
                                }
                                Console.WriteLine("Last name: ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    user.LastName = s;
                                    s             = "";
                                }
                                Console.WriteLine("Email: ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    user.Email = s;
                                    s          = "";
                                }
                                Console.WriteLine("Login:  "******"";
                                }
                                Console.WriteLine("Password:  "******"";
                                }

                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    userService.Update(user);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("User doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 4:
                            Console.Clear();
                            Console.WriteLine("Select User for deleting\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            user = userService.GetById(Id);
                            if (user != null)
                            {
                                Console.WriteLine($"Id: {user.UserId}\nFirst name: {user.FirstName}\nLast name: {user.LastName}\nEmail: {user.Email}\nLogin: {user.Login}\n\n");
                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    userService.Remove(user);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("User doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 5:
                            Console.Clear();
                            Console.WriteLine("Add info about user");

                            UserDTO user1 = new UserDTO();
                            Console.WriteLine("First name: ");
                            user1.FirstName = Console.ReadLine();

                            Console.WriteLine("Last name: ");
                            user1.LastName = Console.ReadLine();

                            Console.WriteLine("Email: ");
                            user1.Email = Console.ReadLine();

                            Console.WriteLine("Login: "******"Password: "******"Roles:");
                            RoleService           rs     = DependencyInjectorUnityBLL.Resolve <RoleService>();
                            IEnumerable <RoleDTO> roles1 = rs.GetAll();
                            foreach (var u in roles1)
                            {
                                Console.WriteLine($"Id: {u.RoleId}\nRole description: {u.RoleDescription}\n");
                            }
                            Console.WriteLine("Choose role: ");
                            user1.RoleId = Convert.ToInt32(Console.ReadLine());


                            Console.WriteLine("Proceed? (Yes/No)");
                            s = Console.ReadLine();
                            if (s.ToLower()[0] == 'y')
                            {
                                userService.Create(user1);
                                Console.WriteLine("Successfully");
                            }

                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 9:
                            cont = false;
                            break;

                        default:
                            Console.WriteLine("Other");
                            break;
                        }
                    }
                    break;

                case 2:
                    AddressService addressService = DependencyInjectorUnityBLL.Resolve <AddressService>();

                    AddressDTO address = new AddressDTO();

                    while (cont)
                    {
                        Console.Clear();
                        Console.WriteLine("Selected Address Table");
                        Console.WriteLine("1 - Show all address");
                        Console.WriteLine("2 - Select address");
                        Console.WriteLine("3 - Update address");
                        Console.WriteLine("4 - Delete address");
                        Console.WriteLine("5 - Create address");
                        Console.WriteLine("9 - Exit");
                        j = Convert.ToInt32(Console.ReadLine());
                        switch (j)
                        {
                        case 1:
                            Console.Clear();
                            Console.WriteLine("All Addresses\n");
                            IEnumerable <AddressDTO> addresses = addressService.GetAll();
                            foreach (var u in addresses)
                            {
                                Console.WriteLine($"Id: {u.AddressId}\nCountry: {u.Country}\nState: {u.State}\nCiry: {u.City}\nPostCode: {u.PostCode}\nUser Id: {u.UserId}\n\n");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 2:
                            Console.Clear();
                            Console.WriteLine("Select Address\n");
                            Console.WriteLine("Enter Id: ");
                            Id      = Convert.ToInt32(Console.ReadLine());
                            address = addressService.GetById(Id);
                            if (address != null)
                            {
                                Console.WriteLine($"Id: {address.AddressId}\nCountry: {address.Country}\nState: {address.State}\nCiry: {address.City}\nPostCode: {address.PostCode}\nUser Id: {address.UserId}\n\n");
                            }
                            else
                            {
                                Console.WriteLine("Address doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 3:
                            Console.Clear();
                            Console.WriteLine("Select Address for updating\n");
                            Console.WriteLine("Enter Id: ");
                            Id      = Convert.ToInt32(Console.ReadLine());
                            address = addressService.GetById(Id);
                            string s = "";

                            if (address != null)
                            {
                                Console.WriteLine($"Id: {address.AddressId}\nCountry: {address.Country}\nState: {address.State}\nCiry: {address.City}\nPostCode: {address.PostCode}\nUser Id: {address.UserId}\n\n");
                                Console.WriteLine("Country: ");
                                s = "";

                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    address.Country = s;
                                    s = "";
                                }
                                Console.WriteLine("City: ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    address.City = s;
                                    s            = "";
                                }
                                Console.WriteLine("State: ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    address.State = s;
                                    s             = "";
                                }
                                Console.WriteLine("Post code:  ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    address.PostCode = Convert.ToInt32(s);
                                    s = "";
                                }
                                Console.WriteLine("User id:  ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    address.UserId = Convert.ToInt32(s);
                                    s = "";
                                }

                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    addressService.Update(address);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Address doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 4:
                            Console.Clear();
                            Console.WriteLine("Select Address for deleting\n");
                            Console.WriteLine("Enter Id: ");
                            Id      = Convert.ToInt32(Console.ReadLine());
                            address = addressService.GetById(Id);
                            if (address != null)
                            {
                                Console.WriteLine($"Id: {address.AddressId}\nCountry: {address.Country}\nState: {address.State}\nCiry: {address.City}\nPostCode: {address.PostCode}\nUser Id: {address.UserId}\n\n");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    addressService.Remove(address);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Address doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 5:
                            Console.Clear();
                            Console.WriteLine("Add info about address");

                            AddressDTO address1 = new AddressDTO();
                            Console.WriteLine("Counrty: ");
                            address1.Country = Console.ReadLine();

                            Console.WriteLine("City: ");
                            address1.City = Console.ReadLine();

                            Console.WriteLine("State: ");
                            address1.State = Console.ReadLine();

                            Console.WriteLine("Post code: ");
                            address1.PostCode = Convert.ToInt32(Console.ReadLine());

                            Console.WriteLine("User id ");
                            address1.UserId = Convert.ToInt32(Console.ReadLine());


                            Console.WriteLine("Proceed? (Yes/No)");
                            s = Console.ReadLine();
                            if (s.ToLower()[0] == 'y')
                            {
                                addressService.Create(address1);
                                Console.WriteLine("Successfully");
                            }

                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 9:
                            cont = false;
                            break;

                        default:
                            Console.WriteLine("Other");
                            break;
                        }
                    }
                    break;

                case 3:
                    RoleService roleService = BLL.DependencyInjectorUnityBLL.Resolve <RoleService>();

                    RoleDTO role1 = new RoleDTO();

                    while (cont)
                    {
                        Console.Clear();
                        Console.WriteLine("Selected User Table");
                        Console.WriteLine("1 - Show all roles");
                        Console.WriteLine("2 - Select role");
                        Console.WriteLine("3 - Update role");
                        Console.WriteLine("4 - Delete role");
                        Console.WriteLine("5 - Create role");
                        Console.WriteLine("9 - Exit");
                        j = Convert.ToInt32(Console.ReadLine());
                        switch (j)
                        {
                        case 1:
                            Console.Clear();
                            Console.WriteLine("All Roles\n");
                            IEnumerable <RoleDTO> roles = roleService.GetAll();
                            foreach (var u in roles)
                            {
                                Console.WriteLine($"Id: {u.RoleId}\nRole description: {u.RoleDescription}\n\n");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 2:
                            Console.Clear();
                            Console.WriteLine("Select User\n");
                            Console.WriteLine("Enter Id: ");
                            Id    = Convert.ToInt32(Console.ReadLine());
                            role1 = roleService.GetById(Id);
                            if (role1 != null)
                            {
                                Console.WriteLine($"Id: {role1.RoleId}\nRole description: {role1.RoleDescription}\n\n");
                            }
                            else
                            {
                                Console.WriteLine("Role doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 3:
                            Console.Clear();
                            Console.WriteLine("Select Role for updating\n");
                            Console.WriteLine("Enter Id: ");
                            Id    = Convert.ToInt32(Console.ReadLine());
                            role1 = roleService.GetById(Id);
                            string s = "";
                            if (role1 != null)
                            {
                                Console.WriteLine($"Id: {role1.RoleId}\nRole description: {role1.RoleDescription}\n\n");
                                Console.WriteLine("Role description: ");
                                s = "";

                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    role1.RoleDescription = s;
                                    s = "";
                                }

                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    roleService.Update(role1);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Role doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 4:
                            Console.Clear();
                            Console.WriteLine("Select Role for deleting\n");
                            Console.WriteLine("Enter Id: ");
                            Id    = Convert.ToInt32(Console.ReadLine());
                            role1 = roleService.GetById(Id);
                            if (role1 != null)
                            {
                                Console.WriteLine($"Id: {role1.RoleId}\nRole description: {role1.RoleDescription}\n\n");
                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    roleService.Remove(role1);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Role doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 5:
                            Console.Clear();
                            Console.WriteLine("Add info about role");

                            RoleDTO role2 = new RoleDTO();
                            Console.WriteLine("Role Description: ");
                            role2.RoleDescription = Console.ReadLine();

                            Console.WriteLine("Proceed? (Yes/No)");
                            s = Console.ReadLine();
                            if (s.ToLower()[0] == 'y')
                            {
                                roleService.Create(role2);
                                Console.WriteLine("Successfully");
                            }

                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 9:
                            cont = false;
                            break;

                        default:
                            Console.WriteLine("Other");
                            break;
                        }
                    }
                    break;

                case 4:
                    CreateCardService cardService = DependencyInjectorUnityBLL.Resolve <CreateCardService>();

                    CreateCardDTO card = new CreateCardDTO();

                    while (cont)
                    {
                        Console.Clear();
                        Console.WriteLine("Selected Create Card Table");
                        Console.WriteLine("1 - Show all card");
                        Console.WriteLine("2 - Select card");
                        Console.WriteLine("3 - Update card");
                        Console.WriteLine("4 - Delete card");
                        Console.WriteLine("5 - Create card");
                        Console.WriteLine("9 - Exit");
                        j = Convert.ToInt32(Console.ReadLine());
                        switch (j)
                        {
                        case 1:
                            Console.Clear();
                            Console.WriteLine("All Cards\n");
                            IEnumerable <CreateCardDTO> cards = cardService.GetAll();
                            foreach (var u in cards)
                            {
                                Console.WriteLine($"Id: {u.CreateCardId}\nCard name: {u.CardName}\nCard number: {u.CardNumber}\nExpire date: {u.ExpireDate.ToString()}\nCVV: {u.Cvv}\nUser Id: {u.UserId}\n\n");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 2:
                            Console.Clear();
                            Console.WriteLine("Select User\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            card = cardService.GetById(Id);
                            if (card != null)
                            {
                                Console.WriteLine($"Id: {card.CreateCardId}\nCard name: {card.CardName}\nCard number: {card.CardNumber}\nExpire date: {card.ExpireDate.ToString()}\nCVV: {card.Cvv}\nUser Id: {card.UserId}\n\n");
                            }
                            else
                            {
                                Console.WriteLine("Card doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 3:
                            Console.Clear();
                            Console.WriteLine("Select Role for updating\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            card = cardService.GetById(Id);
                            string s = "";

                            if (card != null)
                            {
                                Console.WriteLine($"Id: {card.CreateCardId}\nCard name: {card.CardName}\nCard number: {card.CardNumber}\nExpire date: {card.ExpireDate.ToString()}\nCVV: {card.Cvv}\nUser Id: {card.UserId}\n\n");
                                Console.WriteLine("Card name: ");
                                s = "";

                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    card.CardName = s;
                                    s             = "";
                                }
                                Console.WriteLine("Card number: ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    card.CardNumber = s;
                                    s = "";
                                }
                                Console.WriteLine("Expire date: ");
                                s = Console.ReadLine();
                                DateTime dateTime = new DateTime();
                                dateTime = Convert.ToDateTime(s);
                                if (s.Length != 0)
                                {
                                    card.ExpireDate = dateTime;
                                    s = "";
                                }
                                Console.WriteLine("CVV:  ");
                                s = Console.ReadLine();
                                if (s.Length != 0)
                                {
                                    card.Cvv = Convert.ToInt32(s);
                                    s        = "";
                                }

                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    cardService.Update(card);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Card doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 4:
                            Console.Clear();
                            Console.WriteLine("Select Role for deleting\n");
                            Console.WriteLine("Enter Id: ");
                            Id   = Convert.ToInt32(Console.ReadLine());
                            card = cardService.GetById(Id);
                            if (card != null)
                            {
                                Console.WriteLine($"Id: {card.CreateCardId}\nCard name: {card.CardName}\nCard number: {card.CardNumber}\nExpire date: {card.ExpireDate.ToString()}\nCVV: {card.Cvv}\nUser Id: {card.UserId}\n\n");
                                Console.WriteLine("Proceed? (Yes/No)");
                                s = Console.ReadLine();
                                if (s.ToLower()[0] == 'y')
                                {
                                    cardService.Remove(card);
                                    Console.WriteLine("Successfully");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Card doesn`t exist");
                            }
                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 5:
                            Console.Clear();
                            Console.WriteLine("Add info about card");

                            CreateCardDTO card1 = new CreateCardDTO();
                            Console.WriteLine("Card Name: ");
                            card1.CardName = Console.ReadLine();

                            Console.WriteLine("Card Number: ");
                            card1.CardNumber = Console.ReadLine();

                            Console.WriteLine("Expire date: ");
                            card1.ExpireDate = Convert.ToDateTime(Console.ReadLine());

                            Console.WriteLine("CVV: ");
                            card1.Cvv = Convert.ToInt32(Console.ReadLine());

                            Console.WriteLine("User id ");
                            card1.UserId = Convert.ToInt32(Console.ReadLine());


                            Console.WriteLine("Proceed? (Yes/No)");
                            s = Console.ReadLine();
                            if (s.ToLower()[0] == 'y')
                            {
                                cardService.Create(card1);
                                Console.WriteLine("Successfully");
                            }

                            Console.WriteLine("Press any key to return");
                            Console.ReadLine();
                            break;

                        case 9:
                            cont = false;
                            break;

                        default:
                            Console.WriteLine("Other");
                            break;
                        }
                    }
                    break;

                case 9:
                    Continue = false;
                    break;

                default:
                    Console.WriteLine("Other");
                    break;
                }
            }
            Console.WriteLine("Done");
        }
Beispiel #10
0
 public BasicCardDTO Post([FromBody] CreateCardDTO value)
 {
     return(cs.InsertCard(User.Identity.Name, value));
 }