Exemple #1
0
        public BE.Address GetAddByUserId(string userId, bool isOther = false)
        {
            UserProfile user = GetProfile(userId);

            if (user == null)
            {
                return(null);
            }
            string AddressID = isOther ? user.Other_Address_ID : user.Residential_Addess_ID;

            if (string.IsNullOrEmpty(AddressID))
            {
                return(null);
            }

            DBContext.Address addressData = _localUnitOfWork.DataContext.Addresses.FirstOrDefault(a => a.Address_ID == AddressID);

            if (addressData != null)
            {
                var address = new BE.Address
                {
                    Address_ID      = addressData.Address_ID,
                    BlkHouse_Number = addressData.BlkHouse_Number,
                    Country         = addressData.Country,
                    FlrUnit_Number  = addressData.FlrUnit_Number,
                    Postal_Code     = addressData.Postal_Code,
                    Street_Name     = addressData.Street_Name
                };
                return(address);
            }
            return(null);
        }
Exemple #2
0
        private string ProcessSaveAddress(BE.Address model, IUnitOfWork unitOfWork)
        {
            var Repo = unitOfWork.GetRepository <Trinity.DAL.DBContext.Address>();

            if (!string.IsNullOrEmpty(model.Address_ID))
            {
                // Update
                var dbAddress = Repo.GetById(model.Address_ID);
                dbAddress.BlkHouse_Number = model.BlkHouse_Number;
                dbAddress.FlrUnit_Number  = model.FlrUnit_Number;
                dbAddress.Street_Name     = model.Street_Name;
                dbAddress.Country         = model.Country;
                dbAddress.Postal_Code     = model.Postal_Code;
                Repo.Update(dbAddress);
                unitOfWork.Save();
                return(model.Address_ID);
            }
            else
            {
                // Insert
                var dbAddress = new Trinity.DAL.DBContext.Address();
                dbAddress.Address_ID      = Guid.NewGuid().ToString().Trim();
                dbAddress.BlkHouse_Number = model.BlkHouse_Number;
                dbAddress.FlrUnit_Number  = model.FlrUnit_Number;
                dbAddress.Street_Name     = model.Street_Name;
                dbAddress.Country         = model.Country;
                dbAddress.Postal_Code     = model.Postal_Code;
                Repo.Add(dbAddress);
                unitOfWork.Save();
                return(dbAddress.Address_ID);
            }
        }
Exemple #3
0
        public Bitmap DownloadMap(BE.Address address)
        {
            string key = "03jhg7NXBfhDqBHCdDPhM5ywhBiMtn5m";
            //IGeocoder geocoder = new MapQuestGeocoder(key);
            //IEnumerable<Geocoding.Address> addresses = await geocoder.GeocodeAsync(address.ToString());
            //string latlng = addresses.First().Coordinates.Latitude + "," + addresses.First().Coordinates.Longitude;



            // location url
            string url = @"https://www.mapquestapi.com/staticmap/v5/map" +
                         @"?key=" + key +
                         @"&locations=" + address.ToString() +
                         @"&size=500,500@2x";

            //daonload static map as Image to filname loction
            string fileName = Directory.GetCurrentDirectory() + @"\img.jpeg";

            using (WebClient wc = new WebClient())
            {
                wc.DownloadFile(url, fileName);
            }

            //open and convert image to bitmap
            Bitmap bitmap;

            using (Stream bmpStream = File.Open(fileName, FileMode.Open))
            {
                Image image = Image.FromStream(bmpStream);

                bitmap = new Bitmap(image);
            }
            //return image as bitmap
            return(bitmap);
        }
Exemple #4
0
        private void UpdateOrInsert(BE.Address model, IUnitOfWork unitOfWork)
        {
            var AddressRespon = unitOfWork.GetRepository <Trinity.DAL.DBContext.Address>();

            DBContext.Address dbAddress = AddressRespon.GetById(model.Address_ID);
            if (dbAddress == null)
            {
                dbAddress                 = new Trinity.DAL.DBContext.Address();
                dbAddress.Address_ID      = model.Address_ID;
                dbAddress.BlkHouse_Number = model.BlkHouse_Number;
                dbAddress.FlrUnit_Number  = model.FlrUnit_Number;
                dbAddress.Street_Name     = model.Street_Name;
                dbAddress.Country         = model.Country;
                dbAddress.Postal_Code     = model.Postal_Code;
                AddressRespon.Add(dbAddress);
                unitOfWork.Save();
            }
            else
            {
                dbAddress.BlkHouse_Number = model.BlkHouse_Number;
                dbAddress.FlrUnit_Number  = model.FlrUnit_Number;
                dbAddress.Street_Name     = model.Street_Name;
                dbAddress.Country         = model.Country;
                dbAddress.Postal_Code     = model.Postal_Code;
                AddressRespon.Update(dbAddress);
                unitOfWork.Save();
            }
        }
Exemple #5
0
 public string SaveAddress(BE.Address model)
 {
     if (string.IsNullOrEmpty(model.Address_ID))
     {
         model.Address_ID = Guid.NewGuid().ToString().Trim();
     }
     if (EnumAppConfig.IsLocal)
     {
         //bool statusCentralized;
         //CallCentralized.Post("Address", "SaveAddress", out statusCentralized, model);
         //if (!statusCentralized)
         //{
         //    throw new Trinity.Common.ExceptionArgs(EnumMessage.NotConnectCentralized);
         //}
         //else
         //{
         UpdateOrInsert(model, _localUnitOfWork);
         //}
     }
     else
     {
         UpdateOrInsert(model, _centralizedUnitOfWork);
     }
     return(model.Address_ID);
 }
Exemple #6
0
 private void traineeListToUpdateSelectionChangedButton_Click(object sender, RoutedEventArgs e)
 {
     BE.CarType c = new BE.CarType();
     BE.Gender  g = new BE.Gender();
     if (Convert.ToString(BE.CarType.HeavyTruck) == carTypeSpcializesComboBoxToUpdate.Text)
     {
         c = BE.CarType.HeavyTruck;
     }
     if (Convert.ToString(BE.CarType.MediumTruck) == carTypeSpcializesComboBoxToUpdate.Text)
     {
         c = BE.CarType.MediumTruck;
     }
     if (Convert.ToString(BE.CarType.PrivateVehicle) == carTypeSpcializesComboBoxToUpdate.Text)
     {
         c = BE.CarType.PrivateVehicle;
     }
     if (Convert.ToString(BE.CarType.TwoWheeledVehicle) == carTypeSpcializesComboBoxToUpdate.Text)
     {
         c = BE.CarType.TwoWheeledVehicle;
     }
     if (Convert.ToString(BE.Gender.Female) == genderTesterComboBoxToUpdate.Text)
     {
         g = BE.Gender.Female;
     }
     if (Convert.ToString(BE.Gender.Male) == genderTesterComboBoxToUpdate.Text)
     {
         g = BE.Gender.Male;
     }
     BE.Address a = new BE.Address();
     a.street         = streetToUpdate.Text;
     a.buildingNumber = Convert.ToInt32(buildingNumberToUpdate.Text);
     a.city           = cityToUpdate.Text;
     BE.Tester toAdd = new BE.Tester(Convert.ToString(idBoxToUpdate.Text), lastNameBoxToUpdate.Text, firstNameBoxToUpdate.Text, Convert.ToDateTime(dateOfBirthTesterToUpdate.Text), g, Convert.ToInt32(phoneNumberBoxToUpdate.Text), a, Convert.ToInt32(yearsOfExperienceBoxToUpdate.Text), Convert.ToInt32(maxWeeklyTestsBoxToUpdate.Text), c, new bool[6][], Convert.ToInt32(maxDistanceExamBoxToUpdate.Text));
     bl.updateExistTester(toAdd);
 }
Exemple #7
0
        private void UpdateTestButton_Click(object sender, RoutedEventArgs e)
        {
            bool distance, park, mirrors, signals, score;

            if (TestDistancekeepToUpdate.Text == "True")
            {
                distance = true;
            }
            else
            {
                distance = false;
            }
            if (TestParkingInReverseToUpdate.Text == "True")
            {
                park = true;
            }
            else
            {
                park = false;
            }
            if (TestLookingAtMirrorsToUpdate.Text == "True")
            {
                mirrors = true;
            }
            else
            {
                mirrors = false;
            }
            if (TestSignalsToUpdate.Text == "True")
            {
                signals = true;
            }
            else
            {
                signals = false;
            }
            if (TestScoreToUpdate.Text == "True")
            {
                score = true;
            }
            else
            {
                score = false;
            }
            BE.Address a = new BE.Address();
            a.street         = TestStreetToUpdate.Text;
            a.buildingNumber = Convert.ToInt32(TestBuildingNumberToUpdate.Text);
            a.city           = TestCityToUpdate.Text;
            try
            {
                BE.Test toUpdate = new BE.Test(Convert.ToInt32(TestNumberToUpdateTest.Text), Convert.ToString(TestTesterIdToUpdate.Text), Convert.ToString(TestTraineeIdToUpdate.Text), Convert.ToDateTime(TestdateForTestTestToUpdate.Text), Convert.ToDateTime(TestDateAndTimeForTestToUpdate.Text), a, distance, park, mirrors, signals, score, TestTesterCommentToUpdate.Text);
                bl.updateTestAtTheEnd(toUpdate);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            testListBox.DataContext = bl.getTestsList();
        }
Exemple #8
0
        public Response <BE.Address> GetAddressByUserId(string userId, bool isOther = false)
        {
            User_Profiles dbUserProfile = null;

            DBContext.Address dbAddress = null;
            if (EnumAppConfig.IsLocal)
            {
                dbUserProfile = _localUnitOfWork.DataContext.User_Profiles.FirstOrDefault(u => u.UserId == userId);
                if (dbUserProfile != null)
                {
                    var addressId = dbUserProfile.Residential_Addess_ID;
                    if (isOther)
                    {
                        addressId = dbUserProfile.Other_Address_ID;
                    }
                    dbAddress = _localUnitOfWork.DataContext.Addresses.FirstOrDefault(a => a.Address_ID == addressId);
                }
            }
            else
            {
                dbUserProfile = _centralizedUnitOfWork.DataContext.User_Profiles.FirstOrDefault(u => u.UserId == userId);
                if (dbUserProfile != null)
                {
                    var addressId = dbUserProfile.Residential_Addess_ID;
                    if (isOther)
                    {
                        addressId = dbUserProfile.Other_Address_ID;
                    }
                    dbAddress = _centralizedUnitOfWork.DataContext.Addresses.FirstOrDefault(a => a.Address_ID == addressId);
                }
            }

            if (dbUserProfile != null)
            {
                if (dbAddress != null)
                {
                    var address = new BE.Address
                    {
                        Address_ID      = dbAddress.Address_ID,
                        BlkHouse_Number = dbAddress.BlkHouse_Number,
                        Country         = dbAddress.Country,
                        FlrUnit_Number  = dbAddress.FlrUnit_Number,
                        Postal_Code     = dbAddress.Postal_Code,
                        Street_Name     = dbAddress.Street_Name
                    };
                    return(new Response <BE.Address>((int)EnumResponseStatuses.Success, EnumResponseMessage.Success, address));
                }
            }

            return(new Response <BE.Address>((int)EnumResponseStatuses.ErrorSystem, EnumResponseMessage.ErrorSystem, null));
        }
Exemple #9
0
        public string SaveOtherAddress(BE.OtherAddress model)
        {
            if (string.IsNullOrEmpty(model.OAddress_ID))
            {
                model.OAddress_ID = Guid.NewGuid().ToString();
            }

            var add = new BE.Address()
            {
                Address_ID = model.OAddress_ID, BlkHouse_Number = model.OBlkHouse_Number, Country = model.OCountry, FlrUnit_Number = model.OFlrUnit_Number, Postal_Code = model.OPostal_Code, Street_Name = model.OStreet_Name
            };

            UpdateOrInsert(add, _localUnitOfWork);


            return(model.OAddress_ID);
        }
        /// <summary>
        /// find all testers in a cirten distance
        /// </summary>
        public List <BE.Tester> Distance(BE.Address address)
        {
            List <BE.Tester> testers        = Dal.GetTesters();
            List <BE.Tester> return_testers = new List <BE.Tester>();

            Func <BE.Address, BE.Address, double> find_distance = Help_Distance;

            foreach (BE.Tester item in testers)
            {
                double distance = find_distance(address, item.Address);
                if (item.Maximum_distance >= distance)
                {
                    return_testers.Add(item);
                }
            }
            return(return_testers);
        }
Exemple #11
0
        private void AddTestButton_Click(object sender, RoutedEventArgs e)
        {
            BE.Address a = new BE.Address();

            a.street         = TestStreetToAdd.Text;
            a.buildingNumber = Convert.ToInt32(TestBuildingNumberToAdd.Text);
            a.city           = TestCityToAdd.Text;
            BE.Test toAdd = new BE.Test(BE.Configuration.RunningIDNumber, Convert.ToString(TestTesterIdToAdd.Text), Convert.ToString(TestTraineeIdToAdd.Text), Convert.ToDateTime(TestDateForTestToAdd.Text), Convert.ToDateTime(TestDateAndTimeForTestToAdd.Text), a, false, false, false, false, false, "");
            try
            {
                bl.addTest(toAdd);
                MessageBox.Show("Test successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            testListBox.DataContext = bl.getTestsList();
        }
 /// <summary>
 /// find distance between to addresses
 /// </summary>
 private double Help_Distance(BE.Address first_address, BE.Address seconed_address)
 {
     for (int i = 0; i < 3; i++)
     {
         try
         {
             string origin      = first_address.ToString();   //or "תקווה פתח 100 העם אחד "etc.
             string destination = seconed_address.ToString(); //or "גן רמת 10 בוטינסקי'ז "etc.
             string KEY         = @"5rRMSAOyU11mGgkbAlWk3C1y1y0nT2Gv";
             string url         = @"https://www.mapquestapi.com/directions/v2/route" +
                                  @"?key=" + KEY +
                                  @"&from=" + origin +
                                  @"&to=" + destination +
                                  @"&outFormat=xml" +
                                  @"&ambiguities=ignore&routeType=fastest&doReverseGeocode=false" +
                                  @"&enhancedNarrative=false&avoidTimedConditions=false";
             //request from MapQuest service the distance between the 2 addresses
             HttpWebRequest request        = (HttpWebRequest)WebRequest.Create(url);
             WebResponse    response       = request.GetResponse();
             Stream         dataStream     = response.GetResponseStream();
             StreamReader   sreader        = new StreamReader(dataStream);
             string         responsereader = sreader.ReadToEnd();
             response.Close();
             //the response is given in an XML format
             XmlDocument xmldoc = new XmlDocument();
             xmldoc.LoadXml(responsereader);
             if (xmldoc.GetElementsByTagName("statusCode")[0].ChildNodes[0].InnerText == "0")
             //we have the expected answer
             {
                 //display the returned distance
                 XmlNodeList distance    = xmldoc.GetElementsByTagName("distance");
                 double      distInMiles = Convert.ToDouble(distance[0].ChildNodes[0].InnerText);
                 return(distInMiles * 1.609344);
             }
         }
         catch
         {
             Thread.Sleep(500);
         }
     }
     return(BE.Configuration.Defualt_distance);
 }
Exemple #13
0
        public double distance(BE.Address address1, BE.Address address2) //distance in km
        {
            // isRun = true;
            // in the format: @"bergman 5 st. Jerusalem, ISRAEL";
            string origin      = address1.Street + " " + address1.Building_number + " st. " + address1.City + ", ISRAEL";
            string destination = address2.Street + " " + address2.Building_number + " st. " + address2.City + ", ISRAEL";
            string KEY         = @"AyK5ohHf7hbnc8VSnPkdcABB5IgYGmvC";

            string url = @"https://www.mapquestapi.com/directions/v2/route" +
                         @"?key=" + KEY +
                         @"&from=" + origin +
                         @"&to=" + destination +
                         @"&outFormat=xml" +
                         @"&ambiguities=ignore&routeType=fastest&doReverseGeocode=false" +
                         @"&enhancedNarrative=false&avoidTimedConditions=false";

            gMapsThread = new Thread(GetDrivingDistanceInKM);
            gMapsThread.Start(url);
            return(Convert.ToDouble(url));
        }
Exemple #14
0
        public bool ARKUpdateProfile(string UserID, Dictionary <string, Dictionary <string, object> > dataUpdate, List <string> arrayScanDocument, out BE.UserProfile User_Profiles_New, out BE.Address Alternate_Addresses_New, out Guid?IDDocuemnt_Re)
        {
            IDDocuemnt_Re           = null;
            User_Profiles_New       = null;
            Alternate_Addresses_New = null;

            bool isUpdateUser_Profiles = false;
            bool isSaveDataBase        = false;

            CreateUserProfileIfNotExit(UserID);
            Nullable <Guid> IDDocuemnt = null;

            if (arrayScanDocument.Count > 0)
            {
                IDDocuemnt = new DAL_UploadedDocuments().Insert(arrayScanDocument, UserID);
            }

            DAL.DBContext.User_Profiles userProfile         = _localUnitOfWork.DataContext.User_Profiles.FirstOrDefault(d => d.UserId.Equals(UserID));
            DAL.DBContext.Address       Alternate_Addresses = null;
            if (!string.IsNullOrEmpty(userProfile.Other_Address_ID))
            {
                Alternate_Addresses = _localUnitOfWork.DataContext.Addresses.FirstOrDefault(d => d.Address_ID.Equals(userProfile.Other_Address_ID));
            }
            if (dataUpdate.ContainsKey("Alternate_Addresses"))
            {
                if (Alternate_Addresses == null)
                {
                    Alternate_Addresses = new DBContext.Address()
                    {
                        Address_ID = Guid.NewGuid().ToString().Trim()
                    };
                    foreach (var item in dataUpdate["Alternate_Addresses"])
                    {
                        PropertyInfo propertyInfo = Alternate_Addresses.GetType().GetProperty(item.Key);
                        propertyInfo.SetValue(Alternate_Addresses, item.Value == null ? null : Convert.ChangeType(item.Value, propertyInfo.PropertyType), null);
                    }
                    userProfile.Other_Address_ID = Alternate_Addresses.Address_ID;
                    _localUnitOfWork.GetRepository <DAL.DBContext.Address>().Add(Alternate_Addresses);
                    isUpdateUser_Profiles = true;
                    isSaveDataBase        = true;
                }
                else
                {
                    bool isUpdateAddress = false;
                    foreach (var item in dataUpdate["Alternate_Addresses"])
                    {
                        PropertyInfo propertyInfo = Alternate_Addresses.GetType().GetProperty(item.Key);
                        propertyInfo.SetValue(Alternate_Addresses, item.Value == null ? null : Convert.ChangeType(item.Value, propertyInfo.PropertyType), null);
                        isSaveDataBase  = true;
                        isUpdateAddress = true;
                    }
                    if (isUpdateAddress)
                    {
                        _localUnitOfWork.GetRepository <DAL.DBContext.Address>().Update(Alternate_Addresses);
                    }
                }
            }

            if (dataUpdate.ContainsKey("User_Profiles"))
            {
                foreach (var item in dataUpdate["User_Profiles"])
                {
                    PropertyInfo propertyInfo   = userProfile.GetType().GetProperty(item.Key);
                    var          underlyingType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
                    propertyInfo.SetValue(userProfile, item.Value == null ? null : Convert.ChangeType(item.Value, underlyingType ?? propertyInfo.PropertyType), null);
                    isUpdateUser_Profiles = true;
                    isSaveDataBase        = true;
                }
            }

            if (IDDocuemnt.HasValue)
            {
                userProfile.Document_ID = IDDocuemnt.Value;
                isUpdateUser_Profiles   = true;
                isSaveDataBase          = true;
                IDDocuemnt_Re           = IDDocuemnt.Value;
            }



            if ((!userProfile.Employment_Start_Date.HasValue && userProfile.Employment_End_Date.HasValue) || (userProfile.Employment_Start_Date.HasValue && userProfile.Employment_End_Date.HasValue && userProfile.Employment_Start_Date.Value >= userProfile.Employment_End_Date.Value))
            {
                Lib.LayerWeb.ShowMessage("<b>Employment Start Date</b> must be less than <b>Employment End Date</b>");
                return(false);
            }
            else
            {
                if (isUpdateUser_Profiles)
                {
                    _localUnitOfWork.GetRepository <DAL.DBContext.User_Profiles>().Update(userProfile);
                }
                if (isSaveDataBase)
                {
                    _localUnitOfWork.Save();
                }
                User_Profiles_New       = userProfile.Map <BE.UserProfile>();
                Alternate_Addresses_New = Alternate_Addresses.Map <BE.Address>();;
            }
            return(true);
        }
Exemple #15
0
        private void UpdateTesterButton_Click(object sender, RoutedEventArgs e)
        {
            bool[][] schedule = new bool[7][];
            for (int i = 0; i < 7; i++)
            {
                schedule[i] = new bool[5];
            }
            schedule[0][0] = c01.IsChecked.Value;
            schedule[1][0] = c11.IsChecked.Value;
            schedule[2][0] = c21.IsChecked.Value;
            schedule[3][0] = c31.IsChecked.Value;
            schedule[4][0] = c41.IsChecked.Value;
            schedule[5][0] = c51.IsChecked.Value;
            schedule[6][0] = c61.IsChecked.Value;
            schedule[0][1] = c02.IsChecked.Value;
            schedule[1][1] = c12.IsChecked.Value;
            schedule[2][1] = c22.IsChecked.Value;
            schedule[3][1] = c32.IsChecked.Value;
            schedule[4][1] = c42.IsChecked.Value;
            schedule[5][1] = c52.IsChecked.Value;
            schedule[6][1] = c62.IsChecked.Value;
            schedule[0][2] = c03.IsChecked.Value;
            schedule[1][2] = c13.IsChecked.Value;
            schedule[2][2] = c23.IsChecked.Value;
            schedule[3][2] = c33.IsChecked.Value;
            schedule[4][2] = c43.IsChecked.Value;
            schedule[5][2] = c53.IsChecked.Value;
            schedule[6][2] = c63.IsChecked.Value;
            schedule[0][3] = c04.IsChecked.Value;
            schedule[1][3] = c14.IsChecked.Value;
            schedule[2][3] = c24.IsChecked.Value;
            schedule[3][3] = c34.IsChecked.Value;
            schedule[4][3] = c44.IsChecked.Value;
            schedule[5][3] = c54.IsChecked.Value;
            schedule[6][3] = c64.IsChecked.Value;
            schedule[0][4] = c05.IsChecked.Value;
            schedule[1][4] = c15.IsChecked.Value;
            schedule[2][4] = c25.IsChecked.Value;
            schedule[3][4] = c35.IsChecked.Value;
            schedule[4][4] = c45.IsChecked.Value;
            schedule[5][4] = c55.IsChecked.Value;
            schedule[6][4] = c65.IsChecked.Value;

            BE.CarType c = new BE.CarType();
            BE.Gender  g = new BE.Gender();
            if (Convert.ToString(BE.CarType.HeavyTruck) == carTypeSpcializesComboBoxToUpdate.Text)
            {
                c = BE.CarType.HeavyTruck;
            }
            if (Convert.ToString(BE.CarType.MediumTruck) == carTypeSpcializesComboBoxToUpdate.Text)
            {
                c = BE.CarType.MediumTruck;
            }
            if (Convert.ToString(BE.CarType.PrivateVehicle) == carTypeSpcializesComboBoxToUpdate.Text)
            {
                c = BE.CarType.PrivateVehicle;
            }
            if (Convert.ToString(BE.CarType.TwoWheeledVehicle) == carTypeSpcializesComboBoxToUpdate.Text)
            {
                c = BE.CarType.TwoWheeledVehicle;
            }
            if (Convert.ToString(BE.Gender.Female) == genderTesterComboBoxToUpdate.Text)
            {
                g = BE.Gender.Female;
            }
            if (Convert.ToString(BE.Gender.Male) == genderTesterComboBoxToUpdate.Text)
            {
                g = BE.Gender.Male;
            }
            BE.Address a = new BE.Address();
            a.street         = streetToUpdate.Text;
            a.buildingNumber = Convert.ToInt32(buildingNumberToUpdate.Text);
            a.city           = cityToUpdate.Text;
            try
            {
                BE.Tester toUpdate = new BE.Tester(Convert.ToString(idBoxToUpdate.Text), lastNameBoxToUpdate.Text, firstNameBoxToUpdate.Text, Convert.ToDateTime(dateOfBirthTesterToUpdate.Text), g, Convert.ToInt32(phoneNumberBoxToUpdate.Text), a, Convert.ToInt32(yearsOfExperienceBoxToUpdate.Text), Convert.ToInt32(maxWeeklyTestsBoxToUpdate.Text), c, schedule, Convert.ToInt32(maxDistanceExamBoxToUpdate.Text));
                bl.updateExistTester(toUpdate);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            testerListBox.DataContext = bl.getTestersList();
        }
        /// <summary>
        /// Registration of a new student
        /// Enabled when you press a button
        /// </summary>
        private void Registration(object sender, RoutedEventArgs e)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;

                // Determines the student's gender according to what the student chooses
                BE.Gender _gender = BE.Gender.Female;
                try
                {
                    switch (((ComboBoxItem)gender.SelectedItem).Content)
                    {
                    case "בת":
                        _gender = BE.Gender.Female;
                        break;

                    case "בן":
                        _gender = BE.Gender.Male;
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    throw new Exception("אנא בחר מין");
                }

                // Determines the type of vehicle according to what the student chose
                BE.Car_type _type = BE.Car_type.Private_car;
                try
                {
                    switch (((ComboBoxItem)car_type.SelectedItem).Content)
                    {
                    case "רכב פרטי":
                        _type = BE.Car_type.Private_car;
                        break;

                    case "רכב דו-גלגלי":
                        _type = BE.Car_type.Two_wheeled_vehicle;
                        break;

                    case "משאית בינונית":
                        _type = BE.Car_type.Medium_truck;
                        break;

                    case "משאית כבדה":
                        _type = BE.Car_type.Heavy_truck;
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    throw new Exception("אנא בחר סוג רכב");
                }

                // Determines the type of gear box according to what the student chose
                BE.Gearbox_type _gear = BE.Gearbox_type.Manual;
                try
                {
                    switch (((ComboBoxItem)gear.SelectedItem).Content)
                    {
                    case "ידני":
                        _gear = BE.Gearbox_type.Manual;
                        break;

                    case "אוטומטי":
                        _gear = BE.Gearbox_type.Automatic;
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    throw new Exception("אנא בחר סוג גיר");
                }

                // Make sure all fields that must contain numbers contain numbers and not letters
                int b_numer, c_number;
                try
                {
                    b_numer  = Int32.Parse(building_number.Text);
                    c_number = Int32.Parse(number_of_class.Text);
                    Int32.Parse(phone_number.Text);
                }
                catch
                {
                    throw new Exception("אנא וודא שלא הכנסת אותיות או תווים בשדות בהם עליך להכניס מספר");
                }

                // Builds a new address according to the data
                BE.Address address = new BE.Address(street.Text, b_numer, city.Text);

                // Check whether the password and password authentication are correlated
                if (password1.Password != password2.Password)
                {
                    throw new Exception("הסיסמה שהזנת לא תואמת לאימות הסיסמה שהזנת");
                }

                // Builds a new instance of a trainee
                BE.Trainee trainee = new BE.Trainee(id_number.Text, last_name.Text, first_name.Text, (DateTime)birth_date.SelectedDate, _gender, phone_number.Text,
                                                    address, false, _type, _gear, school_name.Text, teacher_name.Text, c_number, iBL_Imp.Encrypte(password1.Password), email.Text);

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (object sender1, DoWorkEventArgs args) =>
                {
                    try
                    {
                        // Moves the rest of the treatment to the BL layer
                        iBL_Imp.Add_traniee(trainee);
                    }
                    catch (Exception ex)
                    {
                        args.Cancel = true;
                        MessageBox.Show(ex.Message);
                        return;
                    }

                    try
                    {
                        // Send email to confirm the email adrress and registration
                        iBL_Imp.Email_Registration(trainee, password1.Password);
                    }
                    catch
                    {
                        MessageBox.Show("המערכת לא הצליחה לשלוח לך אימייל עם אישור ההרשמה שלך. ייתכן שכתובת האימייל שהזנת שגויה או שאין חיבור לאינטרנט\nבאפשרותך לתקן את כתובת האימייל בכל עת במסך עדכון הפרטים אחרי התחברותך למערכת");
                    }
                };
                worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs args) =>
                {
                    if (!args.Cancelled)
                    {
                        // Displays a confirmation message, and closes the window
                        MessageBox.Show("ברוכים הבאים " + first_name.Text + "! אתה רשום במערכת כעת");
                        this.Close();
                    }
                    Mouse.OverrideCursor = null;
                };
                worker.RunWorkerAsync();
            }

            // Displays the contents of the problem, if any
            catch (Exception ex)
            {
                Mouse.OverrideCursor = null;
                MessageBox.Show(ex.Message);
            }
        }
Exemple #17
0
        /// <summary>
        /// Registration of a new student
        /// Enabled when you press a button
        /// </summary>
        private void Registration(object sender, RoutedEventArgs e)
        {
            try
            {
                // Determines the student's gender according to what the student chooses
                BE.Gender _gender = BE.Gender.Female;
                try
                {
                    switch (((ComboBoxItem)gender.SelectedItem).Content)
                    {
                    case "בת":
                        _gender = BE.Gender.Female;
                        break;

                    case "בן":
                        _gender = BE.Gender.Male;
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    throw new Exception("אנא בחר מין");
                }

                // Determines the type of vehicle according to what the student chose
                BE.Car_type _type = BE.Car_type.Private_car;
                try
                {
                    switch (((ComboBoxItem)car_type.SelectedItem).Content)
                    {
                    case "רכב פרטי":
                        _type = BE.Car_type.Private_car;
                        break;

                    case "רכב דו-גלגלי":
                        _type = BE.Car_type.Two_wheeled_vehicle;
                        break;

                    case "משאית בינונית":
                        _type = BE.Car_type.Medium_truck;
                        break;

                    case "משאית כבדה":
                        _type = BE.Car_type.Heavy_truck;
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    throw new Exception("אנא בחר סוג רכב");
                }

                // Make sure all fields that must contain numbers contain numbers and not letters
                int b_numer, e_number, m_number, d_number;
                try
                {
                    b_numer  = Int32.Parse(building_number.Text);
                    e_number = Int32.Parse(years_of_experience.Text);
                    m_number = Int32.Parse(maximum_tests.Text);
                    d_number = Int32.Parse(maximum_distance.Text);
                    Int32.Parse(phone_number.Text);
                }
                catch
                {
                    throw new Exception("אנא וודא שלא הכנסת אותיות או תווים בשדות בהם עליך להכניס מספר");
                }

                // Builds a new address according to the data
                BE.Address address = new BE.Address(street.Text, b_numer, city.Text);

                // Check whether the password and password authentication are correlated
                if (password1.Password != password2.Password)
                {
                    throw new Exception("הסיסמה שהזנת לא תואמת לאימות הסיסמה שהזנת");
                }

                // Builds a new instance of a trainee
                BE.Tester tester = new BE.Tester(id_number.Text, last_name.Text, first_name.Text, (DateTime)birth_date.SelectedDate, _gender,
                                                 phone_number.Text, address, e_number, m_number, _type, matrix, d_number, iBL_Imp.Encrypte(password1.Password));

                // Moves the rest of the treatment to the BL layer, displays a confirmation message, and closes the window
                iBL_Imp.Add_tester(tester);
                MessageBox.Show("ברוכים הבאים " + first_name.Text + "! אתה רשום במערכת כעת");
                this.Close();
            }

            // Displays the contents of the problem, if any
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #18
0
        public void CreateRequest(BE.UserProfile User_Profiles_Old,
                                  BE.Address Alternate_Addresses_Old,
                                  BE.UserProfile User_Profiles_New,
                                  BE.Address Alternate_Addresses_New,
                                  Guid?DocumentID,
                                  bool isScanDocument,
                                  bool isDoLogin
                                  )
        {
            var dataApprove = _localUnitOfWork.DataContext.UpdateProfile_Requests.Where(d => d.UserId == User_Profiles_Old.UserId && d.Status == Enum_UpdateProfile.Approve).OrderByDescending(d => d.UpdatedTime).FirstOrDefault();
            var dataPending = _localUnitOfWork.DataContext.UpdateProfile_Requests.FirstOrDefault(d => d.UserId == User_Profiles_Old.UserId && d.Status == Enum_UpdateProfile.Pending);

            if (dataApprove == null)
            {
                Dictionary <string, object> dataRequest = new Dictionary <string, object>();
                dataRequest.Add("User_Profiles", User_Profiles_Old);
                dataRequest.Add("Alternate_Addresses", Alternate_Addresses_Old);
                dataRequest.Add("UploadedDocuments", new List <Guid>());

                dataApprove = new DBContext.UpdateProfile_Requests()
                {
                    Status               = Enum_UpdateProfile.Approve,
                    UpdatedTime          = DateTime.Now,
                    UserId               = User_Profiles_Old.UserId,
                    VersionId            = Guid.NewGuid().ToString().Trim(),
                    Current_Content_JSON = JsonConvert.SerializeObject(dataRequest)
                };
                _localUnitOfWork.GetRepository <DBContext.UpdateProfile_Requests>().Add(dataApprove);
            }
            if (dataPending == null)
            {
                Dictionary <string, object> dataRequest = new Dictionary <string, object>();
                dataRequest.Add("User_Profiles", User_Profiles_New);
                dataRequest.Add("Alternate_Addresses", Alternate_Addresses_New);
                if (DocumentID.HasValue)
                {
                    dataRequest.Add("UploadedDocuments", new List <Guid>()
                    {
                        DocumentID.Value
                    });
                }
                else
                {
                    dataRequest.Add("UploadedDocuments", new List <Guid>());
                }

                dataPending = new DBContext.UpdateProfile_Requests()
                {
                    Status               = isDoLogin || !isScanDocument ? Enum_UpdateProfile.Approve : Enum_UpdateProfile.Pending,
                    UpdatedTime          = DateTime.Now,
                    UserId               = User_Profiles_Old.UserId,
                    VersionId            = Guid.NewGuid().ToString().Trim(),
                    Current_Content_JSON = JsonConvert.SerializeObject(dataRequest)
                };
                _localUnitOfWork.GetRepository <DBContext.UpdateProfile_Requests>().Add(dataPending);
            }
            else
            {
                Dictionary <string, object> dataRowRequest = JsonConvert.DeserializeObject <Dictionary <string, object> >(dataPending.Current_Content_JSON);
                List <Guid> arrayDocument = JsonConvert.DeserializeObject <List <Guid> >(JsonConvert.SerializeObject(dataRowRequest["UploadedDocuments"]));
                if (DocumentID.HasValue)
                {
                    arrayDocument.Add(DocumentID.Value);
                }
                Dictionary <string, object> dataRequest = new Dictionary <string, object>();
                dataRequest.Add("User_Profiles", User_Profiles_New);
                dataRequest.Add("Alternate_Addresses", Alternate_Addresses_New);
                dataRequest.Add("UploadedDocuments", arrayDocument);
                dataPending.Current_Content_JSON = JsonConvert.SerializeObject(dataRequest);
                dataPending.UpdatedTime          = DateTime.Now;
                if (isDoLogin)
                {
                    dataPending.Status = Enum_UpdateProfile.Approve;
                }

                _localUnitOfWork.GetRepository <DBContext.UpdateProfile_Requests>().Update(dataPending);
            }
            _localUnitOfWork.Save();
        }
Exemple #19
0
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     address           = (BE.Address)DataContext;
     this.DialogResult = true;
     this.Close();
 }
Exemple #20
0
 public Address()
 {
     InitializeComponent();
     address     = new BE.Address();
     DataContext = address;
 }
Exemple #21
0
        private void Save_test(object sender, RoutedEventArgs e)
        {
            try
            {
                pb_save.Visibility = Visibility.Visible;
                pi_save.Visibility = Visibility.Collapsed;

                // Make sure all fields that must contain numbers contain numbers and not letters
                int b_numer;
                try
                {
                    b_numer = Int32.Parse(building_number.Text);
                }
                catch
                {
                    throw new Exception("אנא וודא שלא הכנסת אותיות או תווים בשדות בהם עליך להכניס מספר");
                }

                // Builds a new address according to the data
                BE.Address address = new BE.Address(street.Text, b_numer, city.Text);

                int      hour  = Int32.Parse(((ListViewItem)test_hour.SelectedItem).Content.ToString().Replace(":00", ""));
                DateTime _date = (DateTime)test_date.SelectedDate;
                DateTime date  = new DateTime(_date.Year, _date.Month, _date.Day, hour, 0, 0);

                BE.Test test = new BE.Test(Trainee.ID, date, address, Trainee.Learned);

                if (txt_credit_card_number.Text.Length < 18 || txt_credit_card_date.Text.Length != 5 || txt_credit_card_CVV.Text.Length != 3)
                {
                    throw new Exception("שגיאה בפרטי האשראי: פרטי כרטיס האשראי שהכנסת לא נכונים, או שלא מילאת את כל השדות הדרושים");
                }

                BackgroundWorker worker = new BackgroundWorker()
                {
                    WorkerSupportsCancellation = true
                };
                worker.DoWork += (object sender1, DoWorkEventArgs args) =>
                {
                    try
                    {
                        iBL_Imp.Add_test(test);
                        //iBL_Imp.Send_Email(test);
                        new Thread(() => { iBL_Imp.Send_Email(test); }).Start();
                        args.Cancel = false;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        args.Cancel = true;
                    }
                };
                worker.RunWorkerCompleted += (object sender1, RunWorkerCompletedEventArgs args) =>
                {
                    if (!args.Cancelled)
                    {
                        home_address.IsChecked = false;
                        Home_Address(home_address, null);
                        test_date.SelectedDate      = null;
                        test_hour.SelectedItem      = null;
                        txt_credit_card_date.Text   = "";
                        txt_credit_card_CVV.Text    = "";
                        txt_credit_card_number.Text = "";

                        string           test_data = "נרשמת בהצלחה לטסט ב" + test.Test_time.ToLongDateString() + " בשעה " + test.Test_time.ToShortTimeString() + "\nהטסט מתחיל ב" + test.Address.ToString() + "\nהאם ברצונך להוסיף את הטסט ללוח השנה שלך?";
                        MessageBoxResult result    = MessageBox.Show(test_data, "הטסט נשמר בהצלחה", MessageBoxButton.YesNo);
                        switch (result)
                        {
                        case MessageBoxResult.Yes:
                            iBL_Imp.Add_To_Calender(test);
                            break;

                        default:
                            break;
                        }
                    }

                    pb_save.Visibility = Visibility.Collapsed;
                    pi_save.Visibility = Visibility.Visible;
                };

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                pb_save.Visibility = Visibility.Collapsed;
                pi_save.Visibility = Visibility.Visible;
            }
        }