예제 #1
0
        private void GetStations()
        {
            using (var entities = new MobilekEntities())
            {
                var stations = entities.Stations.AsEnumerable();

                if (!string.IsNullOrWhiteSpace(_searchStreet))
                {
                    stations = stations.Where(s => s.street.StartsWith(_searchStreet));
                }
                if (!string.IsNullOrWhiteSpace(_searchStreetNo))
                {
                    int no;
                    if (Int32.TryParse(_searchStreetNo, out no))
                    {
                        stations = stations.Where(s => s.streetNumer == no);
                    }
                }
                if (!string.IsNullOrWhiteSpace(_searchCity))
                {
                    stations = stations.Where(s => s.city.StartsWith(_searchCity));
                }
                if (!string.IsNullOrWhiteSpace(_searchZipCode))
                {
                    stations = stations.Where(s => s.zipCode.StartsWith(_searchZipCode));
                }
                StationsCollection = ToObservableCollectioncs.ToObservableCollection <Station>(stations);
            }
        }
예제 #2
0
        string GetValidationError(String propertyName)
        {
            switch (propertyName)
            {
            case "Login_UserName":
                if (String.IsNullOrWhiteSpace(Login_UserName))
                {
                    return("Spaces are not allowed in first name");
                }
                else if (String.IsNullOrEmpty(Login_UserName))
                {
                    return("Please enter your user name");
                }
                using (var entities = new MobilekEntities())
                {
                    var user = entities.Workers.FirstOrDefault(x => x.login == Login_UserName);
                    if (user == null)
                    {
                        return("User not found");
                    }
                }
                break;

            case "Login_Password":
                if (String.IsNullOrEmpty(Login_UserName))
                {
                    return("Please enter password!");
                }
                else
                {
                    using (var entities = new MobilekEntities())
                    {
                        var user = entities.Workers.FirstOrDefault(x => x.login == Login_UserName);
                        if (user == null)
                        {
                            return("User not found");
                        }
                        else
                        {
                            if (user.password != Login_Password)
                            {
                                return("Incorrect password");
                            }
                        }
                    }
                }
                break;

            default:
                throw new NotImplementedException("Error name not found");
            }

            return(null);
        }
예제 #3
0
 private void DeleteStation()
 {
     if (SelectedStation != null)
     {
         using (var entities = new MobilekEntities())
         {
             var toRemove = entities.Stations.Single(x => x.Id == SelectedStation.Id);
             entities.Stations.Remove(toRemove);
             entities.SaveChanges();
         }
         GetStations();
     }
 }
예제 #4
0
        string GetValidationError(String propertyName)
        {
            switch (propertyName)
            {
                case "Login_UserName":
                    if (String.IsNullOrWhiteSpace(Login_UserName))
                    {
                        return "Spaces are not allowed in first name";
                    }
                    else if (String.IsNullOrEmpty(Login_UserName))
                    {
                        return "Please enter your user name";
                    }
                    using (var entities = new MobilekEntities())
                    {
                        var user = entities.Workers.FirstOrDefault(x => x.login == Login_UserName);
                        if (user== null)
                        {
                            return "User not found";
                        }
                    }
                        break;
                case "Login_Password":
                    if (String.IsNullOrEmpty(Login_UserName))
                    {
                        return "Please enter password!";
                    }
                    else
                    {
                        using (var entities = new MobilekEntities())
                        {
                            var user = entities.Workers.FirstOrDefault(x => x.login == Login_UserName);
                            if(user== null)
                            {
                                return "User not found";
                            }
                            else
                            {
                                if (user.password != Login_Password)
                                {
                                    return "Incorrect password";
                                }
                            }
                        }
                    }
                    break;
                default:
                    throw new NotImplementedException("Error name not found");
            }

            return null;
        }
예제 #5
0
        private void GetStations()
        {
            using (var entities = new MobilekEntities())
            {
                var stations = entities.Stations.AsEnumerable();

                if (!string.IsNullOrWhiteSpace(_searchStreet))
                {
                    stations = stations.Where(s => s.street.StartsWith(_searchStreet));
                }
                if (!string.IsNullOrWhiteSpace(_searchStreetNo))
                {
                    int no;
                    if (Int32.TryParse(_searchStreetNo, out no))
                    {
                        stations = stations.Where(s => s.streetNumer == no);
                    }
                }
                if (!string.IsNullOrWhiteSpace(_searchCity))
                {
                    stations = stations.Where(s => s.city.StartsWith(_searchCity));
                }
                if (!string.IsNullOrWhiteSpace(_searchZipCode))
                {
                    stations = stations.Where(s => s.zipCode.StartsWith(_searchZipCode));
                }
                StationsCollection = ToObservableCollectioncs.ToObservableCollection<Station>(stations);
            }
        }
예제 #6
0
 private void DeleteStation()
 {
     if(SelectedStation!= null)
     {
         using (var entities = new MobilekEntities())
         {
             var toRemove = entities.Stations.Single(x => x.Id == SelectedStation.Id);
             entities.Stations.Remove(toRemove);
             entities.SaveChanges();
         }
         GetStations();
     }
 }