Exemple #1
0
        public void generateAddressFromUser(User user, int start, int end)
        {
            var addressGenerator = new AddressGenerator(user.getSeed());

            int i;

            for (i = start; i < end; i++)
            {
                AddressTable addr = new AddressTable()
                {
                    Index            = user.AddressIndex + i,
                    generatedAddress = addressGenerator.GetAddress(user.AddressIndex + i).ToString(),
                    UserID           = user.UserID
                };

                _context.AddressTable.Add(addr);
            }

            user.AddressIndex += i;

            var entity = _context.User.Find(user.UserID);

            _context.Entry(entity).CurrentValues.SetValues(user);

            _context.SaveChanges();
        }
Exemple #2
0
        private async Task <Guid> CreateKalleAnkaAsync()
        {
            var person = new PersonTable
            {
                Name = "Kalle Anka"
            };
            var personId = await _storage.Person.CreateAsync(person);

            var address = new AddressTable
            {
                Type     = 1,
                Street   = "Kalles gata",
                City     = "Ankeborg",
                PersonId = personId
            };
            await _storage.Address.CreateAsync(address);

            address = new AddressTable
            {
                Type     = 4,
                Street   = "Box 123",
                City     = "Ankeborg",
                PersonId = personId
            };
            await _storage.Address.CreateAsync(address);

            return(personId);
        }
        internal override void Register(TransportChannelListener channelListener)
        {
            AddressTable.RegisterUri(channelListener.Uri, channelListener.HostNameComparisonModeInternal,
                                     (TChannelListener)channelListener);

            channelListener.SetMessageReceivedCallback(new Action(OnMessageReceived));
        }
        public static int InsertUser(string firstname, string lastname, string birthday,
                                     string phonenumber, string email, string gender, string city,
                                     string street, string login, string type)
        {
            db = new Database();
            db.Connect();

            Address a = new Address(city, street);

            AddressTable.Insert(a);
            a.Id = AddressTable.SelectMaxId(db);

            Person p = new Person(firstname, lastname, birthday, phonenumber, email, gender, a, a.Id);

            PersonTable.Insert(p);
            p.Id = PersonTable.SelectMaxId(db);

            User u = new User(login, type, p, p.Id);

            u.Id = UserTable.SelectMaxId(db);

            int uAdded = UserTable.Insert(u, db);

            db.Close();

            return(uAdded);
        }
Exemple #5
0
        public ArmEmitterContext(
            IMemoryManager memory,
            EntryTable <uint> countTable,
            AddressTable <ulong> funcTable,
            TranslatorStubs stubs,
            ulong entryAddress,
            bool highCq,
            Aarch32Mode mode,
            bool hasTtc)
        {
            Memory = memory;

            CountTable    = countTable;
            FunctionTable = funcTable;
            Stubs         = stubs;

            EntryAddress = entryAddress;
            HighCq       = highCq;
            Mode         = mode;

            HasPtc = Ptc.State != PtcState.Disabled;
            HasTtc = hasTtc;

            _labels = new Dictionary <ulong, Operand>();
        }
 public async Task SaveAddress(AddressTable address)
 {
     try
     {
         var data = await Connection.InsertAsync(address);
     }
     catch (Exception e)
     {
     }
 }
Exemple #7
0
        /* 追加アドレス情報 */
        public void dbAddAdrs(AddressTable AddData)
        {
            DataClassesDataContext db = new DataClassesDataContext();
            DateTime day = DateTime.Today;

            /* 登録日情報を設定 */
            AddData.登録日 = day.Date;

            db.AddressTable.InsertOnSubmit(AddData);
            db.SubmitChanges();
        }
        public override void Start()
        {
            _adtService = ApplicationContext.GetService <IAdtService>();
            _sexChoices = _adtService.GetSexEnumTable();

            _addresses    = new AddressTable();
            _phoneNumbers = new TelephoneNumberTable();
            _toolSet      = new ToolSet(new PatientPreviewToolExtensionPoint(), new PatientPreviewToolContext(this));

            UpdateDisplay();

            base.Start();
        }
        private Address CreateAndMapFromServer(AddressTable source)
        {
            InternalContract.RequireNotNull(source, nameof(source));
            InternalContract.RequireValidated(source, nameof(source));
            var target = new Address
            {
                Type   = MapperHelper.MapToType <string, int>(source.Type),
                Street = source.Street,
                City   = source.City
            };

            FulcrumAssert.IsValidated(target);
            return(target);
        }
Exemple #10
0
        /*  */
        public void dbUpdataAdrs(AddressTable AddData, int id)
        {
            DataClassesDataContext db = new DataClassesDataContext();

            var q = db.AddressTable.Single(x => x.Id == id);

            q.使用者氏名 = AddData.使用者氏名;
            q.アドレス  = AddData.アドレス;
            q.ふりがな  = AddData.ふりがな;
            q.パスワード = AddData.パスワード;
            q.転送先   = AddData.転送先;

            db.SubmitChanges();
        }
Exemple #11
0
 public void AddAddress(int uid, AddressModel model)
 {
     using (ShoppingELFEntities context = new ShoppingELFEntities())
     {
         AddressTable at = new AddressTable()
         {
             AddressLine1 = model.AddressLine1,
             AddressLine2 = model.AddressLine2,
             Pincode      = model.Pincode,
             State        = model.State,
             city         = model.city,
             UserID       = uid
         };
         context.AddressTable.Add(at);
         context.SaveChanges();
     }
 }
        TChannelListener GetChannelListener(Uri via)
        {
            TChannelListener channelListener = null;

            if (AddressTable.TryLookupUri(via, HostNameComparisonMode.StrongWildcard, out channelListener))
            {
                return(channelListener);
            }

            if (AddressTable.TryLookupUri(via, HostNameComparisonMode.Exact, out channelListener))
            {
                return(channelListener);
            }

            AddressTable.TryLookupUri(via, HostNameComparisonMode.WeakWildcard, out channelListener);
            return(channelListener);
        }
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            if (!File.Exists(args[0]))
            {
                return;
            }
            var    lines      = File.ReadAllLines(args[0]);
            var    semantemes = Semanteme.ProcessLines(lines);
            var    table      = new AddressTable(semantemes);
            var    script     = table.ToScript();
            string out_path   = args.Length >= 2 ? args[1] : Path.ChangeExtension(args[0], "avm");

            File.WriteAllBytes(out_path, script);
        }
        private AddressTable ToServer(Guid personId, Address source, bool nullIsOk = false)
        {
            if (nullIsOk && source == null)
            {
                return(null);
            }
            InternalContract.RequireNotNull(source, nameof(source));
            InternalContract.RequireValidated(source, nameof(source));
            var target = new AddressTable
            {
                Type     = MapperHelper.MapToType <int, string>(source.Type),
                Street   = source.Street,
                City     = source.City,
                PersonId = personId
            };

            return(target);
        }
        /// <summary>
        /// Registers and inserts a new customer into the DB
        /// </summary>
        /// <param name="firstname">String first name of the customer</param>
        /// <param name="lastname">String last name of the customer</param>
        /// <param name="password">Password to be hashed</param>
        /// <param name="zip">Int Zip code</param>
        /// <param name="location">String Location name</param>
        /// <param name="streetName">String street name</param>
        /// <param name="houseNumber">Int house/ stairs number</param>
        /// <param name="locationID">int location ID</param>
        /// <returns></returns>
        public bool RegisterNewUser(string firstname, string lastname, string email, string password, int zip, string location, string streetName, int houseNumber, int locationID, string birthDate, string phoneNumber) //Date birthDate
        {
            DataTable userTable = new DataTable();

            try
            {
                // EMAIL VALIDATION
                SQLQueryModel queryBuilder = new SQLQueryModel();
                string        query        = string.Format("SELECT firstName FROM customer WHERE firstName = '{0}' AND lastName = '{1}';", firstname, lastname);
                userTable = queryBuilder.ExecuteMySQLQuery(query);
                if (userTable.Rows.Count != 0)
                {
                    MessageBox.Show("User already exists");
                }
                else
                {
                    #region Create Address Table
                    string insertQuery = "";
                    _addressTable                = new AddressTable();
                    _addressTable.HouseNumber    = houseNumber;
                    _addressTable.LocationID     = locationID;
                    _addressTable.IsValidAddress = true;
                    _addressTable.StreetName     = streetName;
                    insertQuery = string.Format("INSERT INTO address(locationID, streetName, houseNumber) VALUES('{0}','{1}','{2}');", _addressTable.LocationID, streetName, houseNumber);
                    queryBuilder.ExecuteMySQLQuery(insertQuery);
                    #endregion
                    #region Create Customer Table
                    insertQuery = "";
                    DataTable       addressTable = new DataTable();
                    EncryptionModel encryption   = new EncryptionModel();
                    //insertQuery = string.Format("INSERT INTO customer(firstName, lastName, customerpwd, email, addressID, birthDate) VALUES('{0}','{1}','{2}', '{3}',(SELECT LAST_INSERT_ID(),'{4}'));", firstname, lastname, encryption.EncryptPassword(password), email ,birthdate);
                    insertQuery = string.Format("INSERT INTO customer(firstName, lastName, customerpwd, email, addressID, birthDate, phoneNumber) VALUES('{0}','{1}','{2}','{3}',(SELECT LAST_INSERT_ID()),'{4}','{5}');", firstname, lastname, encryption.EncryptPassword(password), email, birthDate, phoneNumber);
                    queryBuilder.ExecuteMySQLQuery(insertQuery);
                    MessageBox.Show("User " + firstname + " " + lastname + " has successfully been created");
                    #endregion
                }
            }
            catch (ArgumentNullException nullex)
            {
                Protocol.WriteToProtocol(0, "RegisterNewUser() :" + nullex.Message + nullex.StackTrace, "User already exists Error");
            }
            return(true);
        }
Exemple #16
0
        public async Task <IActionResult> MakeConnectionAsync(User model)
        {
            //Get both userIDs
            User temp  = HttpContext.Session.GetObjectFromJson <User>("User");
            User userA = _context.User.Single(m => m.UserID == temp.UserID);
            User userB = _context.User.Single(m => m.Name == model.Name);

            //check if connection already exists!
            Connections testConn = await GetConnectionFromTwoIDsAsync(userB.UserID, userA.UserID);

            if (testConn != null)
            {
                TempData["msg"] = "<script>alert('Connection Already established');</script>";
                return(RedirectToAction("Overview"));
            }

            //Get Open addresses:
            AddressTable addrA = _context.AddressTable.First(m => m.UserID == userA.UserID);
            AddressTable addrB = _context.AddressTable.First(m => m.UserID == userB.UserID);

            Connections conn = new Connections {
                UserA_        = userA,
                UserB_        = userB,
                AddressA      = addrA.generatedAddress,
                AddressB      = addrB.generatedAddress,
                Refresh_A     = false,
                Refresh_B     = false,
                EncryptionKey = generateEncryptionKey()
            };

            _context.Connections.Add(conn);

            //generate a new address for your own user:
            generateAddressFromUser(userA, userA.AddressIndex, userA.AddressIndex + 1);

            //remove addresses out of the list
            _context.AddressTable.RemoveRange(addrA, addrB);

            _context.SaveChanges();

            return(RedirectToAction("ChatAsync", new { id = HttpContext.Session.GetObjectFromJson <User>("SelectedUser")?.Name }));
        }
Exemple #17
0
        public async Task ThenTheAddressSectionIsReturned(Table table)
        {
            var expected = table.CreateSet <AddressTable>().FirstOrDefault();
            var response = (await _response.ReadBodyAsJsonAsync()).SelectToken("address");

            var actual = new AddressTable
            {
                Line1    = response.Value <string>("line1"),
                Line2    = response.Value <string>("line2"),
                Line3    = response.Value <string>("line3"),
                Line4    = response.Value <string>("line4"),
                Line5    = response.Value <string>("line5"),
                Town     = response.Value <string>("town"),
                County   = response.Value <string>("county"),
                Postcode = response.Value <string>("postcode"),
                Country  = response.Value <string>("country")
            };

            actual.Should().BeEquivalentTo(expected);
        }
Exemple #18
0
        /// <summary>
        /// 从控件信息中获取提示信息
        /// 如果参数index非-1则返回对应序号的参数提示信息
        /// 否则返回所有参数的提示信息
        /// </summary>
        /// <param name="ctrl">控件信息</param>
        /// <param name="index">参数序号</param>
        /// <returns>提示信息</returns>
        public void GetTipmessage(ControlInfo ctrl, int index)
        {
            List <string> TipMes = new List <string>(); //返回用的信息数组
            string        tip    = null;                //提示

            if (ctrl.VisibleFunctionProperty.Count == 0 && ctrl.UnvisibleFunctionProperty.Count == 0)
            {//默认功能属性为空则没有参数提示信息
                this.toolTip1.Hide(this);
                return;
            }
            if (index == -1)
            {//查找全部的参数信息
                int paraCount = 0;

                //foreach (XProp element in ctrl.VisibleFunctionProperty)
                //{
                //    tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName;
                //    if (TipMes.Count % 4 == 3)//每行3个参数
                //    { tempMes = "\n" + tempMes; }
                //    TipMes.Add(tempMes);
                //}
                foreach (XProp element in ctrl.UnvisibleFunctionProperty)
                {
                    if (element.TheValue.ToString().Contains("array"))
                    {
                        //tempMes = AddressTable.ConvertShowType(element.ValueType) + " " + element.VarName;
                        //if (TipMes.Count % 4 == 3)
                        //{ tempMes = "\n" + tempMes; }
                        //TipMes.Add(tempMes);
                        paraCount++;
                    }
                }
                paraCount += ctrl.VisibleFunctionProperty.Count;
                if (this.toolTip1.ToolTipTitle != ctrl.SortName)
                { //控件中文名作标题
                    this.toolTip1.ToolTipTitle = ctrl.SortName;
                }

                if (PLCCodeEditor.CanTipCode.Contains(ctrl.CodeInfo[1]))
                {
                    tip += "1个参数";
                }
                else if (paraCount == 0)
                {
                    tip += "无参数";
                }
                else
                {
                    tip += paraCount + "个参数";
                }

                tip += "\n" + ctrl.OtherProperty[2];

                this.toolTip1.Show(tip, this, new Point(Size.Width, 0));
                //return TipMes;
            }
            else if (ctrl.VisibleFunctionProperty.Count != 0)
            {                        //查找制定参数信息
                int   ParaCount = 0; //数组参数个数 在不可见功能属性遍历中记录所用
                XProp tempFun   = new XProp();

                if (index < ctrl.VisibleFunctionProperty.Count)
                {//查找序号小于可见功能属性
                    tempFun = ctrl.VisibleFunctionProperty[index];
                }
                //else
                //{
                for (int x = 0; x < ctrl.UnvisibleFunctionProperty.Count; x++)
                {
                    if (ctrl.UnvisibleFunctionProperty[x].TheValue.ToString().Contains("array"))
                    {     //不可见数组参数
                        if (index == ParaCount + ctrl.VisibleFunctionProperty.Count)
                        { //序号符合
                            tempFun = ctrl.UnvisibleFunctionProperty[x];
                        }
                        ParaCount++;
                    }
                }
                //}
                //string tip = AddressTable.ConvertShowType(tempFun.ValueType) + " " + tempFun.VarName;
                //if (index <= ParaCount + ctrl.VisibleFunctionProperty.Count - 1)
                //{
                //    if (index != ParaCount + ctrl.VisibleFunctionProperty.Count - 1)
                //    {//当不为最后一个参数
                //        tip = tip + ",...";
                //    }
                //    if (index != 0)
                //    { //当不为第一个参数
                //        tip = "...," + tip;
                //    }
                //    //类型后换行加入描述信息
                //    tip += "\n" + tempFun.Name + ":\n" + tempFun.ValueExplain;

                //    TipMes.Add(tip);
                //}
                string title = tempFun.Name + " (" + (index + 1) + "/" + (ParaCount + ctrl.VisibleFunctionProperty.Count) + ")";
                tip = AddressTable.ConvertShowType2(tempFun.ValueType) + "\n";
                for (int i = 0; i < tempFun.ValueExplain.Length; i++)
                {
                    if (i % 11 == 0)
                    {//11个字符换行
                        tip += "\n";
                    }
                    tip += tempFun.ValueExplain[i];
                }
                if (this.toolTip1.ToolTipTitle != title)
                {
                    this.toolTip1.ToolTipTitle = title;
                }
                this.toolTip1.Show(tip, this, new Point(Size.Width, 0));
            }
            //return TipMes;
        }
 internal override void Unregister(TransportChannelListener channelListener)
 {
     EnsureRegistered(AddressTable, (TChannelListener)channelListener, channelListener.HostNameComparisonModeInternal);
     AddressTable.UnregisterUri(channelListener.Uri, channelListener.HostNameComparisonModeInternal);
     channelListener.SetMessageReceivedCallback(null);
 }
Exemple #20
0
        public override Users Create(Users obj)
        {
            Users result = null;

            using (SqlConnection objConn = new SqlConnection(connection))
            {
                objConn.Open();
                using (var myTran = new TransactionScope())
                {
                    if (obj.Logging_ID == null)
                    {
                        try
                        {
                            AspNetUsers logging = new AspNetUsers
                            {
                                Id                   = obj.AspNetUsers.UserName,
                                EmailConfirmed       = false,
                                PhoneNumberConfirmed = false,
                                TwoFactorEnabled     = false,
                                LockoutEnabled       = false,
                                AccessFailedCount    = 0,
                                UserName             = obj.AspNetUsers.UserName,
                                PasswordHash         = obj.AspNetUsers.PasswordHash,
                                Email                = obj.AspNetUsers.Email,
                                PhoneNumber          = obj.AspNetUsers.PhoneNumber,
                                AvailabilityState    = _context.GetTable <AvailabilityState>().First(x => x.ID == 1).ID,
                            };
                            _context.GetTable <AspNetUsers>().InsertOnSubmit(logging);
                            _context.SubmitChanges();

                            var addressExists = _context.GetTable <AddressTable>().FirstOrDefault(t => t.Postcode == obj.AddressTable.Postcode);
                            if (addressExists == null)
                            {
                                addressExists = new AddressTable
                                {
                                    Postcode = obj.AddressTable.Postcode,
                                    City     = obj.AddressTable.City,
                                    Region   = obj.AddressTable.Region,
                                };
                                _context.GetTable <AddressTable>().InsertOnSubmit(addressExists);


                                _context.SubmitChanges();
                            }

                            Users u = new Users
                            {
                                FirstName  = obj.FirstName,
                                LastName   = obj.LastName,
                                Logging_ID = logging.Id,
                                Gender_ID  = _context.GetTable <Repository.DbConnection.Gender>().FirstOrDefault(
                                    t => t.Gender1 == obj.Gender.Gender1.ToString()).ID,
                                AddressLine = obj.AddressLine,
                                City_ID     = addressExists.ID,
                                PayPalMail  = obj.PayPalMail,
                            };

                            _context.GetTable <Users>().InsertOnSubmit(u);
                            _context.SubmitChanges();

                            myTran.Complete();
                            result = u;
                        }
                        catch
                        {
                            result = null;
                            throw new DuplicateKeyException(this);
                        }
                        finally
                        {
                            myTran.Dispose();
                            objConn.Close();
                        }
                    }
                    else
                    {
                        try
                        {
                            var addressExists = _context.GetTable <AddressTable>().FirstOrDefault(t => t.Postcode == obj.AddressTable.Postcode);
                            if (addressExists == null)
                            {
                                addressExists = new AddressTable
                                {
                                    Postcode = obj.AddressTable.Postcode,
                                    City     = obj.AddressTable.City,
                                    Region   = obj.AddressTable.Region,
                                };
                                _context.GetTable <AddressTable>().InsertOnSubmit(addressExists);


                                _context.SubmitChanges();
                            }

                            Users u = new Users
                            {
                                FirstName  = obj.FirstName,
                                LastName   = obj.LastName,
                                Logging_ID = obj.Logging_ID,
                                Gender_ID  = _context.GetTable <Repository.DbConnection.Gender>().FirstOrDefault(
                                    t => t.Gender1 == obj.Gender.Gender1.ToString()).ID,
                                AddressLine = obj.AddressLine,
                                City_ID     = addressExists.ID,
                                PayPalMail  = obj.PayPalMail,
                            };

                            _context.GetTable <Users>().InsertOnSubmit(u);
                            _context.SubmitChanges();

                            myTran.Complete();
                            result = u;
                        }
                        catch
                        {
                            result = null;
                            throw new DuplicateKeyException(this);
                        }
                        finally
                        {
                            myTran.Dispose();
                            objConn.Close();
                        }
                    }
                }
            }
            return(result);
        }
Exemple #21
0
        public void InitLocalMySQL()
        {
            if (this.Database.CreateIfNotExists())
            {
                EntityGenerator <Address> generatorAddress = new EntityGenerator <Address>();
                for (int i = 0; i < 10; i++)
                {
                    AddressTable.Add(generatorAddress.GenerateItem());
                }

                EntityGenerator <StreetNumber> generatorStreetNumber = new EntityGenerator <StreetNumber>();
                for (int i = 0; i < 20; i++)
                {
                    StreetNumberTable.Add(generatorStreetNumber.GenerateItem());
                }

                EntityGenerator <Employee> generatorEmployee = new EntityGenerator <Employee>();
                for (int i = 0; i < 10; i++)
                {
                    EmployeeTable.Add(generatorEmployee.GenerateItem());
                }

                EntityGenerator <Animal> generatorAnimal = new EntityGenerator <Animal>();
                for (int i = 0; i < 10; i++)
                {
                    AnimalTable.Add(generatorAnimal.GenerateItem());
                }

                EntityGenerator <Job> generatorJob = new EntityGenerator <Job>();
                for (int i = 0; i < 10; i++)
                {
                    JobTable.Add(generatorJob.GenerateItem());
                }

                EntityGenerator <Schedule> generatorSchedule = new EntityGenerator <Schedule>();
                for (int i = 0; i < 10; i++)
                {
                    ScheduleTable.Add(generatorSchedule.GenerateItem());
                }


                EntityGenerator <Structure> generatorStructure = new EntityGenerator <Structure>();
                for (int i = 0; i < 10; i++)
                {
                    StructureTable.Add(generatorStructure.GenerateItem());
                }

                EntityGenerator <Zoo> generatorZoo = new EntityGenerator <Zoo>();
                for (int i = 0; i < 10; i++)

                {
                    ZooTable.Add(generatorZoo.GenerateItem());
                }

                this.SaveChangesAsync();


                AddressTable.Find(1).StreetNumber = StreetNumberTable.Find(1);
                this.SaveChangesAsync();
            }
        }
Exemple #22
0
        static void Main(string[] args)
        {
            Database db = new Database();

            db.Connect();


            /***1.1 Vloženie užívateľa***/
            Address a1 = new Address("Bratislava", "Lomnická 9");

            AddressTable.Insert(a1);
            a1.Id = AddressTable.SelectMaxId(db);

            Person p1 = new Person("Lukáš", "Náhodný", "1996-10-12", "+421" + RandomString("number", 9),
                                   RandomString("word", 5) + "@email.com", "muz", a1, a1.Id);

            PersonTable.Insert(p1);
            p1.Id = PersonTable.SelectMaxId(db);


            User u1 = new User((p1.LastName.Substring(0, 3) + RandomString("number", 4)).ToLower(),
                               "courier", p1, p1.Id);

            UserTable.Insert(u1);
            u1.Id = UserTable.SelectMaxId(db);



            /***1.2 Aktualizácia užívateľa***/
            p1.LastName = "Aktualizovaný";
            PersonTable.Update(p1);
            u1.Login = (p1.LastName.Substring(0, 3) + RandomString("number", 4)).ToLower();
            UserTable.Update(u1);


            /***1.3 Zrušenie užívateľa**/
            //int UserToDelete = 15;
            //UserTable.Delete(UserToDelete);
            //PersonTable.Delete(UserToDelete);
            //Console.WriteLine("User with ID " + UserToDelete + " has been deleted." );
            //Console.WriteLine(" ");

            List <Shipment> Shipments2 = ShipmentTable.SelectAllShipments(db);

            foreach (var shipment in Shipments2)
            {
                Console.WriteLine(shipment.Id);
            }

            /*List<Shipment> ShipmentsD = ShipmentTable.SelectShipmentDetail(21,db);
             *
             * foreach (var shipment in ShipmentsD)
             * {
             *  Console.WriteLine(shipment.Id.ToString() +  shipment.Type + " " + shipment.Price + " " + shipment.DeliveryPrice + " " +
             *      shipment.Weight + " " + shipment.OrderTime + " " + shipment.DeliveryTime);
             * }*/


            /**1.4 Zoznam užívateľov**/
            List <User> Users = UserTable.SelectUsers(db);

            Console.WriteLine("(1.4)User list");

            foreach (var user in Users)
            {
                Console.WriteLine("  " + user.Id + "  " + user.Person.FullName + " " + user.Login + "   " +
                                  user.Type + " " + user.Person.Email + " " + user.Person.Address.City + "...");
            }
            Console.WriteLine(" ");


            /***1.5 Detail užívateľa***/
            User UserDetail = UserTable.SelectUser(p1.Id, db);

            Console.WriteLine("(1.5)User detail with ID: " + p1.Id + " " + UserDetail.Person.FullName + " " +
                              UserDetail.Login + " " + UserDetail.Type + " " + UserDetail.Person.Address.City + "....");
            Console.WriteLine(" ");


            /***2.1 Zoznam neskoro doručených zásielok (podľa id kuriéra)***/
            int             CourierToCheckId = 3;
            List <Shipment> LateShipments    = ShipmentTable.SelectLateShipmentsByCourierId(CourierToCheckId, db);

            Console.WriteLine("(2.1)Late shipments by courier id");

            foreach (var shipment in LateShipments)
            {
                Console.WriteLine(" " + shipment.Id.ToString() + " with " + shipment.Delay.ToString() + " day(s) delay. " + "Delivered " +
                                  shipment.Delivered + " instead of " + shipment.DeliveryTime);
            }
            Console.WriteLine(" ");


            /***2.2 Ukončené zásielky***/
            string StateToCheck = "zrusena zakaznikom"; /*vyzdvihnuta, nevyzdvihnuta*/

            ;           List <Shipment> DoneShipments = ShipmentTable.SelectDoneShipmentsByState(StateToCheck, db);
            Console.WriteLine("(2.2)Done shipments by state");

            foreach (var shipment in DoneShipments)
            {
                Console.WriteLine(" " + shipment.Id + " done at " + shipment.DoneAt);
            }
            Console.WriteLine(" ");


            /***2.3 Nedoručené zásielky***/
            int             IdOfCourierChecking = 5;
            List <Shipment> NotDoneShipments    = ShipmentTable.SelectNotDoneShipmentsByCourierId(IdOfCourierChecking, db);

            Console.WriteLine("(2.3)My shipments to deliver");

            foreach (var shipment in NotDoneShipments)
            {
                Console.WriteLine(" " + shipment.Id + " should be delivered at " + shipment.DeliveryTime +
                                  " to " + shipment.Person.FullName);
            }
            Console.WriteLine(" ");


            /***2.4 Počet jednotlivých zásielok pre ich stavy (u každého kuriéra)***/
            List <User> ShipmentsByState = ShipmentTable.SelectShipmentsByState(db);

            Console.WriteLine("(2.4)Shipment count by its state with courierID");
            Console.WriteLine(" " + "Courier ID" + "   Picked   Not Picked   Canceled   On way");

            foreach (var user in ShipmentsByState)
            {
                Console.WriteLine("      " + user.Id + "         " + user.CourPicked + "         " + user.CourNotPicked
                                  + "            " + user.CourCanceled + "         " + user.CourOnWay);
            }
            Console.WriteLine(" ");


            /***2.5 Aktuálne meškajúce zásielky (kuriéra)***/
            List <Shipment> CurrLateShipments = ShipmentTable.SelectCurrLateShipmentsByCourierId(7, db);

            Console.WriteLine("(2.5)My currently late shipments");

            foreach (var shipment in CurrLateShipments)
            {
                Console.WriteLine(" " + shipment.Id + " should be delivered " + shipment.Delay + " day(s) ago.");
            }
            Console.WriteLine(" ");

            /***3.3 Vloženie novej zásielky a automatická aktualizácia cien a váhy***/
            Console.WriteLine("(3.3)Adding new shipment...");
            Person p2 = new Person("Neregistrovaný", "Užívateľ", "1996-10-12", "+421" + RandomString("number", 9),
                                   RandomString("word", 5) + "@email.com", "muz", a1, a1.Id);

            PersonTable.Insert(p2);
            p2.Id = PersonTable.SelectMaxId(db);

            string productIds            = "4,5,6"; /* ID produtkov, ktoré si užívateľ vyberie v rozhraní*/;
            String CreateAndUpdateResult = ShipmentTable.CreateAndUpdateShipment("Test funkcie 3.3.", p2.Id, 1, 4, 2, productIds, db);

            Console.WriteLine(CreateAndUpdateResult);
            Console.WriteLine(" ");

            /***3.4 Automatická aktualizácia ceny doručenia pri oneskorenom doručení a upozornenie zákazníka o tejto udalosti***/
            Console.WriteLine("(3.4)Updating shipment delivery prices and sending notifications...");
            Console.WriteLine(ShipmentTable.LateShipNotificationAndUpdate("Ospravedlňujeme sa za meškanie vašej zásielky.", db));
            Console.WriteLine(" ");

            /***3.5 História a pohyb zásielky***/
            String Updated = ShipmentTable.HistoryAndMovement(11122, "zrusena zakaznikom", 4, db);

            Console.WriteLine("(3.5) " + Updated);

            Console.ReadLine();


            db.Close();
        }
        private async void ExceuteRegisterCommand(object obj)
        {
            if (Settings.Role != "admin")
            {
                AddressService address     = new AddressService();
                AddressTable   addressdata = new AddressTable()
                {
                    City = this.City, Country = this.Country, PostCode = this.PostalCode, State = this.State, Street = this.Street
                };
                await address.SaveAddress(addressdata);

                DocumentTable documentTable = new DocumentTable()
                {
                    Base64String = this.DocumentName
                };
                DocumentService documentService = new DocumentService();
                await documentService.SaveDocument(documentTable);

                StudentTable studentTable = new StudentTable()
                {
                    AddressID      = addressdata.AddressId,
                    DocumentID     = documentTable.DocumentId,
                    ISAuditable    = "false",
                    StudentClass   = this.StudentClass,
                    StudentContact = this.Number,
                    StudentEmail   = this.Email,
                    StudentGender  = this.IsFemale == true ? "FeMale" : "Male",
                    StudentName    = this.Username,
                    StudnetDOB     = this.DOB.ToString(),
                    UserID         = this._StudentTable.UserID
                };

                RegistrationService registrationService = new RegistrationService();
                registrationService.DeleteStudent(_StudentTable);
                var row = await registrationService.SaveStudent(studentTable);

                if (row != 0)
                {
                    await Application.Current.MainPage.DisplayAlert("Success", "Update SuccessFull", "Cancel");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error", " Data Not Updated ", "Cancel");
                }
            }
            else
            {
                //StudentTable studentTable = obj as StudentTable;
                RegistrationService registrationService = new RegistrationService();
                var row = await registrationService.UpdateStudent(_StudentTable);

                if (row != 0)
                {
                    await Application.Current.MainPage.DisplayAlert("Success", "Audit update  SuccessFull", "Cancel");
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Error", " Audit Not Updated ", "Cancel");
                }
            }
        }