Beispiel #1
0
        public void SaveChanges() // Edit or Add Order data and save it to DB
        {
            string emailPattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";

            if (!String.IsNullOrEmpty(InputName) ||
                !String.IsNullOrEmpty(InputSurname) ||
                !String.IsNullOrEmpty(InputEmail) ||
                !String.IsNullOrEmpty(InputPhone))
            {
                if (InputPhone.Length < 11 || InputPhone.Any(Char.IsLetter) || !InputPhone.StartsWith("7"))
                {
                    string message         = "Phone must have 11 digits and start with 7.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else if (Regex.IsMatch(InputEmail, emailPattern) == false)
                {
                    string message         = "Incorrect email format.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else if (SelectedGender == Genders[0] || SelectedGender == null)
                {
                    string message         = "You need to select gender.";
                    var    exceptionWindow = new ExceptionWindow(message);
                    exceptionWindow.ShowDialog();
                }
                else
                {
                    if (_currentClient == null)
                    {
                        _currentClient = new Client()
                        {
                            Name      = InputName,
                            Surname   = InputSurname,
                            Phone     = InputPhone,
                            Email     = InputEmail,
                            Gender    = SelectedGender,
                            LastVisit = DateTime.Parse("01/01/01"),
                        };
                        context.Client.Add(_currentClient);
                    }
                    else
                    {
                        _currentClient.Name    = InputName;
                        _currentClient.Surname = InputSurname;
                        _currentClient.Phone   = InputPhone;
                        _currentClient.Email   = InputEmail;
                        _currentClient.Gender  = SelectedGender;
                    }
                    context.SaveChanges();
                }
            }
            else
            {
                string message         = "You need to complete all the fields.";
                var    exceptionWindow = new ExceptionWindow(message);
                exceptionWindow.ShowDialog();
            }
        }
Beispiel #2
0
 public AllInfoBonus Discounts([FromBody] InputPhone pPh)
 {
     if (pPh == null || string.IsNullOrEmpty(pPh.phone))
     {
         return(new AllInfoBonus(-1, "Невірні вхідні дані"));
     }
     return(Bl.GetBonusAsync(pPh).Result);
 }
Beispiel #3
0
 public Status Auth([FromBody] InputPhone pUser)
 {
     if (pUser == null || string.IsNullOrEmpty(pUser.phone))
     {
         return(new Status(-1, "Невірні вхідні дані"));
     }
     return(Bl.Auth(pUser));
 }
Beispiel #4
0
        public InfoForRegister GetInfoForRegister([FromBody] InputPhone pUser)
        {
            if (pUser == null || string.IsNullOrEmpty(pUser.phone))
            {
                return(new InfoForRegister(-1, "Невірні вхідні дані"));
            }

            return(Bl.GetInfoForRegister());
        }
Beispiel #5
0
        public Promotion ActionsList([FromBody] InputPhone pUser)
        {
            if (pUser == null || string.IsNullOrEmpty(pUser.phone))
            {
                return(new Promotion(-1, "Невірні вхідні дані"));
            }

            return(Bl.GetPromotion());
        }
Beispiel #6
0
        public StatusData FindByPhoneNumber([FromBody] InputPhone pUser)
        {
            if (pUser == null || string.IsNullOrEmpty(pUser.ShortPhone))
            {
                return(new StatusData(-1, "Невірні вхідні дані"));
            }

            return(Bl.FindByPhoneNumber(pUser));
        }