Example #1
0
        public void saveClientInfo(ClientInterestViewModel clientInterestViewModel)
        {
            Client client = new Client();

            client.UserId    = clientInterestViewModel.userId;
            client.UserName  = clientInterestViewModel.userName;
            client.gender    = clientInterestViewModel.gender;
            client.email     = clientInterestViewModel.email;
            client.country   = clientInterestViewModel.country;
            client.province  = clientInterestViewModel.province;
            client.city      = clientInterestViewModel.city;
            client.birthdate = clientInterestViewModel.birthdate;
            client.latitude  = clientInterestViewModel.latitude;
            client.longitude = clientInterestViewModel.longitude;

            db.Clients.Add(client);
            db.SaveChanges();

            foreach (string interest in clientInterestViewModel.interests)
            {
                ClientInterest clientInterest = new ClientInterest();
                clientInterest.UserName = clientInterestViewModel.userName;
                clientInterest.interest = interest;
                db.ClientInterests.Add(clientInterest);
            }

            db.SaveChanges();
        }
Example #2
0
        public void updatgeProfile(Client clientUpdate, string[] interests, string country, string state)
        {
            //udpate client table
            Client client = db.Clients.Find(clientUpdate.UserName);

            if (clientUpdate.gender != null)
            {
                client.gender = clientUpdate.gender;
            }

            if (clientUpdate.birthdate != null)
            {
                client.birthdate = clientUpdate.birthdate;
            }

            if (country != null && country != "")
            {
                client.country = country;
            }

            if (state != null && state != "")
            {
                client.province = state;
            }

            if (interests != null)
            {
                var queryInterests = from c_i in db.ClientInterests where c_i.UserName == clientUpdate.UserName select c_i;

                if (queryInterests != null)
                {
                    foreach (var interest in queryInterests)
                    {
                        db.ClientInterests.Remove(interest);
                    }
                }


                foreach (string interest in interests)
                {
                    ClientInterest clientInterest = new ClientInterest();
                    clientInterest.UserName = clientUpdate.UserName;
                    clientInterest.interest = interest;

                    db.ClientInterests.Add(clientInterest);
                }
            }



            db.SaveChanges();
        }
        public void updatgeProfile(Client clientUpdate, string[] interests, string country, string state)
        {
            //udpate client table
            Client client = db.Clients.Find(clientUpdate.UserName);
            if (clientUpdate.gender != null)
            {
            client.gender = clientUpdate.gender;
            }

            if(clientUpdate.birthdate != null)
            {
            client.birthdate = clientUpdate.birthdate;
            }

            if(country!=null && country != "")
            {
                client.country = country;
            }

            if(state !=null && state != "")
            {
                client.province = state;

            }

            if (interests != null)
            {
                var queryInterests = from c_i in db.ClientInterests where c_i.UserName == clientUpdate.UserName select c_i;

                if (queryInterests != null)
                {
                    foreach (var interest in queryInterests)
                    {
                        db.ClientInterests.Remove(interest);
                    }
                }

                foreach (string interest in interests)
                {
                    ClientInterest clientInterest = new ClientInterest();
                    clientInterest.UserName = clientUpdate.UserName;
                    clientInterest.interest = interest;

                    db.ClientInterests.Add(clientInterest);
                }
            }

            db.SaveChanges();
        }
        public void saveClientInfo(ClientInterestViewModel clientInterestViewModel)
        {
            Client client = new Client();
            client.UserId = clientInterestViewModel.userId;
            client.UserName = clientInterestViewModel.userName;
            client.gender = clientInterestViewModel.gender;
            client.email = clientInterestViewModel.email;
            client.country = clientInterestViewModel.country;
            client.province = clientInterestViewModel.province;
            client.city = clientInterestViewModel.city;
            client.birthdate = clientInterestViewModel.birthdate;
            client.latitude = clientInterestViewModel.latitude ;
            client.longitude = clientInterestViewModel.longitude;

            db.Clients.Add(client);
            db.SaveChanges();

            foreach (string interest in clientInterestViewModel.interests)
            {
                ClientInterest clientInterest = new ClientInterest();
                clientInterest.UserName = clientInterestViewModel.userName;
                clientInterest.interest = interest;
                db.ClientInterests.Add(clientInterest);
            }

            db.SaveChanges();
        }