コード例 #1
0
        public IActionResult BlockClient(int id)
        {
            var client = _client.Read(new ClientBindingModel {
                Id = id
            }).FirstOrDefault();

            var blocked = !client.Blocked;

            if (client.Id == Program.Client.Id)
            {
                Program.Client.Blocked = blocked;
            }

            _client.CreateOrUpdate(new ClientBindingModel
            {
                Id       = client.Id,
                Login    = client.Login,
                Password = client.Password,
                Email    = client.Email,
                Phone    = client.Phone,
                Blocked  = blocked
            });

            return(RedirectToAction("Clients"));
        }
コード例 #2
0
        public ViewResult Registration(RegistrationModel client)
        {
            // if (ModelState.IsValid)
            //{
            var existClient = _client.Read(new ClientBindingModel
            {
                Login = client.Login
            }).FirstOrDefault();

            if (existClient != null)
            {
                ModelState.AddModelError("", "Данный логин уже занят");
                return(View(client));
            }
            existClient = _client.Read(new ClientBindingModel
            {
                Mail = client.Email
            }).FirstOrDefault();
            if (existClient != null)
            {
                ModelState.AddModelError("", "Данный E-Mail уже занят");
                return(View(client));
            }
            _client.CreateOrUpdate(new ClientBindingModel
            {
                ClientFIO = client.ClientFIO,
                Login     = client.Login,
                Password  = client.Password,
                Mail      = client.Email
            });
            ModelState.AddModelError("", "Вы успешно зарегистрированы");
            return(View("Registration", client));
            //}
            // return View(client);
        }
コード例 #3
0
 public ViewResult AddClient(AddClientModel client)
 {
     if (String.IsNullOrEmpty(client.Pasport))
     {
         ModelState.AddModelError("", "Введите номер паспорта");
         return(View(client));
     }
     if (!Regex.IsMatch(client.Pasport, @"^[1-9]{10}$"))
     {
         ModelState.AddModelError("", "Паспорт введен некорректно");
         return(View(client));
     }
     if (_client.Read(new ClientBindingModel {
         Pasport = client.Pasport
     }).Count != 0)
     {
         ModelState.AddModelError("", "Такой паспорт уже существует");
         return(View(client));
     }
     if (client.Pasport.Length != 10)
     {
         ModelState.AddModelError("", "Паспорт состоит из 10 цифр");
         return(View(client));
     }
     if (String.IsNullOrEmpty(client.Email))
     {
         ModelState.AddModelError("", "Введите Email");
         return(View(client));
     }
     if (!Regex.IsMatch(client.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
     {
         ModelState.AddModelError("", "Email введен некорректно");
         return(View(client));
     }
     if (String.IsNullOrEmpty(client.ClientFIO))
     {
         ModelState.AddModelError("", "Введите ФИО");
         return(View(client));
     }
     if (String.IsNullOrEmpty(client.PhoneNumber))
     {
         ModelState.AddModelError("", "Введите номер телефона");
         return(View(client));
     }
     if (!Regex.IsMatch(client.PhoneNumber, @"^[1-9]{1}[0-9]{5,10}"))
     {
         ModelState.AddModelError("", "Заполните телефон правильно: 89176258099 или 565656");
         return(View(client));
     }
     _client.CreateOrUpdate(new ClientBindingModel
     {
         ClientFIO   = client.ClientFIO,
         Pasport     = client.Pasport,
         Email       = client.Email,
         PhoneNumber = client.PhoneNumber,
         UserId      = 0
     });
     ModelState.AddModelError("", "Вы успешно зарегистрированы");
     return(View("AddClient", client));
 }
        public void CheckingForBlockingClients(ChangeStatusClientaBindingModel model)
        {
            var visit = visitLogic.Read(new VisitBindingModel
            {
                Id = model.VisitId
            })?[0];
            var client = clientLogic.Read(new ClientBindingModel
            {
                VisitId = model.VisitId,
                Id      = model.ClientId
            })?[0];

            if (client == null)
            {
                throw new Exception("Не найден клиент");
            }
            if ((visit.Status == VisitStatus.Неоплачен) && (visit.DateCreate.AddMonths(6) <= DateTime.Now))
            {
                clientLogic.CreateOrUpdate(new ClientBindingModel
                {
                    Id      = client.Id,
                    VisitId = client.Id,
                    Status  = ClientStatus.Заблокирован
                });
            }
        }
コード例 #5
0
 private void buttonBan_Click(object sender, EventArgs e)
 {
     if (dataGridView.SelectedRows.Count == 1)
     {
         int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
         try
         {
             logic.CreateOrUpdate(new ClientBindingModel
             {
                 Id        = id,
                 isBlocked = true
             });
         } catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
         LoadData();
     }
 }
コード例 #6
0
        public ViewResult Registration(RegistrationModel user)
        {
            if (String.IsNullOrEmpty(user.Login))
            {
                ModelState.AddModelError("", "Введите логин");
                return(View(user));
            }
            if (user.Login.Length > loginMaxLength ||
                user.Login.Length < loginMinLength)
            {
                ModelState.AddModelError("", $"Длина логина должна быть от {loginMinLength} до {loginMaxLength} символов");
                return(View(user));
            }
            var existClient = client.Read(new ClientBindingModel
            {
                Login = user.Login
            }).FirstOrDefault();

            if (existClient != null)
            {
                ModelState.AddModelError("", "Уже есть клиент с таким логином");
                return(View(user));
            }
            if (!Regex.IsMatch(user.Login, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
            {
                ModelState.AddModelError("", "логин введен некорректно");
                return(View(user));
            }
            if (user.Password.Length > passwordMaxLength ||
                user.Password.Length < passwordMinLength)
            {
                ModelState.AddModelError("", $"Длина пароля должна быть от {passwordMinLength} до {passwordMaxLength} символов");
                return(View(user));
            }
            if (String.IsNullOrEmpty(user.ClientFIO))
            {
                ModelState.AddModelError("", "Введите ФИО");
                return(View(user));
            }
            if (String.IsNullOrEmpty(user.Password))
            {
                ModelState.AddModelError("", "Введите пароль");
                return(View(user));
            }
            client.CreateOrUpdate(new ClientBindingModel
            {
                ClientFIO   = user.ClientFIO,
                Login       = user.Login,
                Password    = user.Password,
                BlockStatus = false
            });
            ModelState.AddModelError("", "Вы успешно зарегистрированы");
            return(View("Registration", user));
        }
コード例 #7
0
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textBoxEmail.Text) && !string.IsNullOrEmpty(textBoxPassword.Text) && !string.IsNullOrEmpty(textBoxClientFIO.Text))
     {
         try
         {
             if (Program.Client == null)
             {
                 logic.CreateOrUpdate(new ClientBindingModel
                 {
                     Email     = textBoxEmail.Text,
                     Password  = textBoxPassword.Text,
                     ClientFIO = textBoxClientFIO.Text,
                 });
             }
             else
             {
                 logic.CreateOrUpdate(new ClientBindingModel
                 {
                     Email     = textBoxEmail.Text,
                     Password  = textBoxPassword.Text,
                     ClientFIO = textBoxClientFIO.Text,
                     Id        = Program.Client.Id,
                     IsAdmin   = Program.Client.IsAdmin
                 });
             }
             MessageBox.Show("Регистрация прошла успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Введите логин, пароль и ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #8
0
 public ViewResult Registration(RegistrationModel client)
 {
     if (ModelState.IsValid)
     {
         var existClient = logic.Read(new ClientBindingModel
         {
             Email = client.Email
         }).FirstOrDefault();
         if (existClient != null)
         {
             ModelState.AddModelError("", "Данный E-Mail уже занят");
             return(View(client));
         }
         logic.CreateOrUpdate(new ClientBindingModel
         {
             ClientFIO = client.ClientFIO,
             Password  = client.Password,
             Email     = client.Email
         });
         ModelState.AddModelError("", "Вы успешно зарегистрированы");
     }
     return(View("Registration", client));
 }
コード例 #9
0
 public ActionResult BlockStatus(int id)
 {
     if (ModelState.IsValid)
     {
         var existClient = _client.Read(new ClientBindingModel
         {
             Id = id
         }).FirstOrDefault();
         _client.CreateOrUpdate(new ClientBindingModel
         {
             Id          = id,
             ClientFIO   = existClient.ClientFIO,
             Login       = existClient.Login,
             Password    = existClient.Password,
             BlockStatus = !existClient.BlockStatus
         });
         return(RedirectToAction("Blocking"));
     }
     return(RedirectToAction("Blocking"));
 }
コード例 #10
0
ファイル: AdminController.cs プロジェクト: Shpula/KursWork
 public ActionResult Block(int id)
 {
     if (ModelState.IsValid)
     {
         var existClient = _client.Read(new ClientBindingModel
         {
             Id = id
         }).FirstOrDefault();
         _client.CreateOrUpdate(new ClientBindingModel
         {
             Id             = id,
             Email          = existClient.Email,
             Specialication = existClient.Specialication,
             Login          = existClient.Login,
             Password       = existClient.Password,
             Block          = !existClient.Block
         });
         return(RedirectToAction("Blocking"));
     }
     return(RedirectToAction("Blocking"));
 }
コード例 #11
0
 public ActionResult Block(int id)
 {
     if (ModelState.IsValid)
     {
         var existClient = _client.Read(new ClientBindingModel
         {
             Id = id
         }).FirstOrDefault();
         _client.CreateOrUpdate(new ClientBindingModel
         {
             Id          = id,
             FirstName   = existClient.FirstName,
             SecondName  = existClient.SecondName,
             Patronymic  = existClient.Patronymic,
             Email       = existClient.Email,
             Password    = existClient.Password,
             PhoneNumber = existClient.PhoneNumber,
             Block       = !existClient.Block
         });
         return(RedirectToAction("Blocking"));
     }
     return(RedirectToAction("Blocking"));
 }
コード例 #12
0
 public void Register(ClientBindingModel model)
 {
     CheckData(model);
     _logic.CreateOrUpdate(model);
 }
コード例 #13
0
ファイル: ClientController.cs プロジェクト: Shpula/KursWork
        public ViewResult Registration(RegistrationModel client)
        {
            if (String.IsNullOrEmpty(client.Login))
            {
                ModelState.AddModelError("", "Введите логин");
                return(View(client));
            }
            if (client.Login.Length > loginMaxLength ||
                client.Login.Length < loginMinLength)
            {
                ModelState.AddModelError("", $"Длина логина должна быть от {loginMinLength} до {loginMaxLength} символов");
                return(View(client));
            }
            var existClient = _client.ReadofRegistration(new ClientBindingModel
            {
                Login = client.Login
            }).FirstOrDefault();

            if (existClient != null)
            {
                ModelState.AddModelError("", "Данный логин уже занят");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Email))
            {
                ModelState.AddModelError("", "Введите электронную почту");
                return(View(client));
            }
            existClient = _client.ReadofRegistration(new ClientBindingModel
            {
                Email = client.Email
            }).FirstOrDefault();
            if (existClient != null)
            {
                ModelState.AddModelError("", "Данный E-Mail уже занят");
                return(View(client));
            }
            if (!Regex.IsMatch(client.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
            {
                ModelState.AddModelError("", "Email введен некорректно");
                return(View(client));
            }
            if (client.Password.Length > passwordMaxLength ||
                client.Password.Length < passwordMinLength)
            {
                ModelState.AddModelError("", $"Длина пароля должна быть от {passwordMinLength} до {passwordMaxLength} символов");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Specialication))
            {
                ModelState.AddModelError("", "Введите Specialication");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Password))
            {
                ModelState.AddModelError("", "Введите пароль");
                return(View(client));
            }
            _client.CreateOrUpdate(new ClientBindingModel
            {
                Specialication = client.Specialication,
                Login          = client.Login,
                Password       = client.Password,
                Email          = client.Email,
                Block          = false
            });
            ModelState.AddModelError("", "Вы успешно зарегистрированы");
            return(View("Registration", client));
        }
コード例 #14
0
        public ViewResult Registration(ClientRegistrationModel client)
        {
            if (String.IsNullOrEmpty(client.SecondName))
            {
                ModelState.AddModelError("", "Введите фамилию");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.FirstName))
            {
                ModelState.AddModelError("", "Введите имя");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Patronymic))
            {
                ModelState.AddModelError("", "Введите отчество");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.PhoneNumber))
            {
                ModelState.AddModelError("", "Введите телефон");
                return(View(client));
            }
            if (!Regex.IsMatch(client.PhoneNumber, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$"))
            {
                ModelState.AddModelError("", "Номер телефона введен некорректно");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Email))
            {
                ModelState.AddModelError("", "Введите E-Mail");
                return(View(client));
            }
            if (!Regex.IsMatch(client.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
            {
                ModelState.AddModelError("", "E-Mail введен некорректно");
                return(View(client));
            }
            if (String.IsNullOrEmpty(client.Password))
            {
                ModelState.AddModelError("", "Введите пароль");
                return(View(client));
            }
            if (client.Password.Length < 5 || client.Password.Length > 40)
            {
                ModelState.AddModelError("", "Пароль должен быть не менее 5 и не более 40 символов");
                return(View(client));
            }
            var existClientEmail = _client.Read(new ClientBindingModel
            {
                Email = client.Email
            }).FirstOrDefault();

            if (existClientEmail != null)
            {
                ModelState.AddModelError("", "Данный E-Mail уже занят");
                return(View(client));
            }
            var existClientPhone = _client.Read(new ClientBindingModel
            {
                PhoneNumber = client.PhoneNumber
            }).FirstOrDefault();

            if (existClientPhone != null)
            {
                ModelState.AddModelError("", "Данный номер телефона уже занят");
                return(View(client));
            }
            _client.CreateOrUpdate(new ClientBindingModel
            {
                FirstName   = client.FirstName,
                SecondName  = client.SecondName,
                Patronymic  = client.Patronymic,
                Email       = client.Email,
                Block       = false,
                Password    = client.Password,
                PhoneNumber = client.PhoneNumber
            });
            ModelState.AddModelError("", "Регистрация успешна");
            return(View("Registration", client));
        }
コード例 #15
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxFIO.Text))
            {
                MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxGender.Text))
            {
                MessageBox.Show("Заполните пол", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxNumber.Text))
            {
                MessageBox.Show("Заполните номер телефона", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxCount.Text))
            {
                MessageBox.Show("Заполните количество билетов", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            if (string.IsNullOrEmpty(textBoxCount.Text))
            {
                MessageBox.Show("Заполните Email", "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            Random rnd   = new Random();
            var    list  = new List <TicketClientBindingModel>();
            int    count = Convert.ToInt32(textBoxCount.Text);
            var    lis   = new List <int>();

            for (int j = 0; j < 10; j++)
            {
                lis.Add(j);
            }
            for (int i = 0; i < count; i++)
            {
                if (!lis.Any())
                {
                    MessageBox.Show("Недостаточно билетов", "Ошибка", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    break;
                }
                int temp = lis[rnd.Next(0, lis.Count)];
                list.Add(new TicketClientBindingModel {
                    ClientId = id, TicketId = temp
                });
                lis.Remove(temp);
            }
            try
            {
                logic.CreateOrUpdate(new ClientBindingModel
                {
                    Id            = id,
                    ClientFIO     = textBoxFIO.Text,
                    Gender        = textBoxGender.Text,
                    Number        = Convert.ToInt32(textBoxNumber.Text),
                    Email         = textBoxEmail.Text,
                    CountTicket   = Convert.ToInt32(textBoxCount.Text),
                    Score         = CalculateSum(list),
                    TicketClients = list
                });
                MessageBox.Show("Сохранение прошло успешно", "Сообщение",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }