示例#1
0
        public SetUserInfo()
        {
            this.InitializeComponent();

            ObservableCollection<int> ages = new ObservableCollection<int>();
            for(int i = 1; i < 100; i++) { ages.Add(i); }
            cmbAge.ItemsSource = ages;
            ObservableCollection<int> heights = new ObservableCollection<int>();
            for (int i = 100; i < 250; i++) { heights.Add(i); }
            cmbHeight.ItemsSource = heights;
            ObservableCollection<int> weights = new ObservableCollection<int>();
            for (int i = 30; i < 200; i++) { weights.Add(i); }
            cmbWeight.ItemsSource = weights;

            if (MiBand.Band != null)
            {
                userInfo = Entities.UserInfo.FromSetting((ApplicationDataCompositeValue)MiBand.Band.SettingGet("UserInfo"));
                Alias  = userInfo.Alias;
                Male   = userInfo.Male;
                Female = !userInfo.Male;
                InfoAge    = userInfo.Age;
                InfoHeight = userInfo.Height;
                InfoWeight = userInfo.Weight;

                cmbAge.SelectedIndex = userInfo.Age - 1;
                cmbHeight.SelectedIndex = userInfo.Height - 100;
                cmbWeight.SelectedIndex = userInfo.Weight - 30;
            }
            if (userInfo == null)
            {
                Debugger.Break();
            }
            LayoutRoot.DataContext = this;
        }
示例#2
0
 public IHttpActionResult SaveUserInfo(Entities.UserInfo entity)
 {
     return(ApiResult <bool>(() =>
     {
         return this.CoreBusinessRules.SaveUserInfo(entity);
     }));
 }
示例#3
0
文件: DAL.cs 项目: jemsgit/Blog
 public bool SaveDate(Entities.UserInfo info)
 {
     using (SqlConnection con = new SqlConnection(ConnectionString))
     {
         SqlCommand command = new SqlCommand("UPDATE dbo.UserAbout SET Birthday = @Birthday WHERE Login = @Login", con);
         if (info.Birthday == null)
         {
             command.Parameters.Add(new SqlParameter("@Birthday", DBNull.Value));
         }
         else
         {
             command.Parameters.Add(new SqlParameter("@Birthday", info.Birthday));
         }
         command.Parameters.Add(new SqlParameter("@Login", info.Login));
         con.Open();
         int count = command.ExecuteNonQuery();
         if (count > 0)
         {
             logger.Info("DB: Данные о дате рождения пользователя сохранены: " + info.Login);
             return(true);
         }
         else
         {
             logger.Error("DB: Ошибка записи данных о дате рождения пользователя: " + info.Login);
             return(false);
         }
     }
 }
示例#4
0
文件: DAL.cs 项目: jemsgit/Blog
        public Entities.UserInfo GetUserInfo(string name)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand command = new SqlCommand("SELECT Sex, Birthday, True_Name, About FROM dbo.UserAbout RIGHT JOIN Users ON Users.Login = UserAbout.Login Where Users.Login = @Login", con);
                command.Parameters.Add(new SqlParameter("@Login", name));
                con.Open();
                Entities.UserInfo info = new Entities.UserInfo()
                {
                    Login = name
                };
                int count  = 0;
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    if (DBNull.Value.Equals(reader["Sex"]))
                    {
                        info.Sex = null;
                    }
                    else
                    {
                        info.Sex = (string)reader["Sex"];
                    }
                    if (DBNull.Value.Equals(reader["Birthday"]))
                    {
                        info.Birthday = null;
                    }
                    else
                    {
                        info.Birthday = (DateTime)reader["Birthday"];
                    }
                    if (DBNull.Value.Equals(reader["True_Name"]))
                    {
                        info.Name = null;
                    }
                    else
                    {
                        info.Name = (string)reader["True_Name"];
                    }
                    if (DBNull.Value.Equals(reader["About"]))
                    {
                        info.AboutMe = null;
                    }
                    else
                    {
                        info.AboutMe = (string)reader["About"];
                    }
                    count++;
                }
                if (count < 0)
                {
                    return(info = null);
                }
                else
                {
                    return(info);
                }
            }
        }
示例#5
0
 private async void btnSave_Click(object sender, RoutedEventArgs e)
 {
     // recuperamos del combobox el manejo de los datos
     ComboBoxItem cbi = cmbDataMode.SelectedItem as ComboBoxItem;
     DataMode mode = (DataMode)Int32.Parse((string)cbi.Tag);
     // cogemos el perfil actual
     Entities.UserInfo currentUserInfo = Entities.UserInfo.FromSetting((ApplicationDataCompositeValue)MiBand.Band.SettingGet("UserInfo"));
     // FIXME el comparador no funciona, necesita uno personalizado
     if (currentUserInfo != userInfo)
     {
         // si difiere lo cambiamos
         await MiBand.Band.SetUserInfo(userInfo, mode);
     }
     if (initialSetup)
     {
         this.Frame.Navigate(typeof(SetDailyGoal), "InitialSetup");
         return;
     }
     this.Frame.GoBack();
 }
示例#6
0
文件: DAL.cs 项目: jemsgit/Blog
 public bool SaveAbout(Entities.UserInfo info)
 {
     using (SqlConnection con = new SqlConnection(ConnectionString))
     {
         SqlCommand command = new SqlCommand("UPDATE dbo.UserAbout SET About = @About WHERE Login = @Login", con);
         command.Parameters.Add(new SqlParameter("@About", info.AboutMe));
         command.Parameters.Add(new SqlParameter("@Login", info.Login));
         con.Open();
         int count = command.ExecuteNonQuery();
         if (count > 0)
         {
             logger.Info("DB: Данные о пользователе сохранены: " + info.Login);
             return(true);
         }
         else
         {
             logger.Error("DB: Ошибка записи данных о пользователе: " + info.Login);
             return(false);
         }
     }
 }
示例#7
0
        public ActionResult EditEmployee(EmployeeInfoModel model)
        {
            Entities.UserInfo userInfo = new Entities.UserInfo()
            {
                Address  = model.Address,
                Email    = model.Email,
                ID       = model.ID,
                Name     = model.Name,
                UserName = model.UserName
            };
            if (model.NewPassword != null && model.ConfirmPassword != null && model.NewPassword == model.ConfirmPassword)
            {
                userInfo.Password = model.NewPassword;
            }
            else
            {
                if ((model.NewPassword == null && model.ConfirmPassword != null) || (model.NewPassword != null && model.ConfirmPassword == null))
                {
                    ViewBag.Error = "Password and Confirm Password is not matched";
                    return(View(model));
                }
            }
            Entities.Employee employee = new Entities.Employee()
            {
                E_ID   = model.ID,
                Salary = model.Salary
            };
            var result = EmployeeInfoRepo.editEmployee(userInfo, employee);

            if (result.HasError)
            {
                ViewBag.Error = result.Message;
                return(View(model));
            }
            ViewBag.Success = "Informations have been updated successfully";
            return(View(model));
        }
示例#8
0
        public ActionResult EditCustomer(CustomerInfoModel model)
        {
            Entities.UserInfo userInfo = new Entities.UserInfo()
            {
                Address  = model.Address,
                Email    = model.Email,
                ID       = model.ID,
                Name     = model.Name,
                UserName = model.UserName
            };
            if (model.NewPassword != null && model.ConfirmPassword != null && model.NewPassword == model.ConfirmPassword)
            {
                userInfo.Password = model.NewPassword;
            }
            else
            {
                if ((model.NewPassword == null && model.ConfirmPassword != null) || (model.NewPassword != null && model.ConfirmPassword == null))
                {
                    ViewBag.Error = "Password and Confirm Password is not matched";
                    return(View(model));
                }
            }
            Entities.Customer customer = new Entities.Customer()
            {
                C_ID = model.ID,
                Rate = model.Rate
            };
            var result = CustomerInfoRepo.editCustomers(userInfo, customer);

            if (result.HasError)
            {
                ViewBag.Error = result.Message;
                return(View(model));
            }
            ViewBag.Success = "Informations have been updated successfully";
            return(View(model));
        }
        public void GivenUserEntityAndPasswordInfo_MapPasswordInfoCorrectlyMapsPasswordInfoToUserEntity_WhenCalled()
        {
            //arrange
            var passwordInfo = new DTOs.PasswordInfo
            {
                salt = "salt"
            };
            var crypto = new System.Security.Cryptography.SHA512Managed();

            passwordInfo.hash = crypto.ComputeHash(System.Text.Encoding.ASCII.GetBytes("apassword"));

            var userInfo = new Entities.UserInfo
            {
                email = "anemail",
                id    = 1
            };
            var userEntity = new Entities.User
            {
                id       = 1,
                userinfo = userInfo,
                username = "******"
            };

            var sut = new Mappings.UserEntityMapper();

            //act
            userEntity = sut.MapPasswordInfo(userEntity, passwordInfo);

            //assert
            Assert.AreEqual(userEntity.username, "username");
            Assert.AreEqual(userEntity.id, 1);
            Assert.AreEqual(userEntity.pwhash, passwordInfo.hash);
            Assert.AreEqual(userEntity.salt, passwordInfo.salt);
            Assert.AreEqual(userEntity.userinfo.email, "anemail");
            Assert.AreEqual(userEntity.userinfo.id, 1);
        }
示例#10
0
        public void getTest()
        {

            var u = new Entities.UserInfo()
            {
                name = "测试",
                department = new int[] { 1 },
                mobile = "15111111111",
                extattr = new Entities.UserInfo.Extattr
                {
                    attrs = new Entities.UserInfo.Extattr.NameValuePair[] {
                        new Entities.UserInfo.Extattr.NameValuePair { name = "hello", value = "hi" } }
                }
            };


            var userid = DD.User.create(u);
            Assert.IsNotNull(userid);



            var user = DD.User.get(userid);
            Assert.IsNotNull(user);
            Assert.IsNotNull(user.extattr.attrs);
            Assert.IsTrue(user.extattr.attrs.Length > 0);
            Assert.AreEqual(user.extattr.attrs[0].value, "hi");
            Assert.AreEqual(user.name, "测试");



            user.email = "*****@*****.**";
            var isupdated = DD.User.update(user);
            Assert.IsTrue(isupdated);

            user = DD.User.get(userid);
            Assert.AreEqual(user.email, "*****@*****.**");

            var isdeleted = DD.User.delete(userid);
            Assert.IsTrue(isdeleted);



            string[] ids = new string[10];
            for (int i = 0; i < ids.Length; i++)
            {
                u = new Entities.UserInfo()
                {
                    name = "测试" + i,
                    department = new int[] { 1 },
                    mobile = "1511111112" + i,
                    extattr = new Entities.UserInfo.Extattr
                    {
                        attrs = new Entities.UserInfo.Extattr.NameValuePair[] {
                        new Entities.UserInfo.Extattr.NameValuePair { name = "hello", value = "hi" } }
                    }
                };
                userid = DD.User.create(u);
                Assert.IsNotNull(userid);
                ids[i] = userid;


            }


            isdeleted = DD.User.batchdelete(ids);
            Assert.IsTrue(isdeleted);
        }
示例#11
0
        //判断是否给父用户返现
        //本过程应该用事务处理
        void ParentUserOrderCash(Entities.UserInfo user, Entities.OrderInfo order)
        {
            if (order.couponid <= 0)
            {
                return;
            }

            var dbh = Common.CommonService.Resolve <Common.DB.IDBHelper>();

            var coupon = dbh.GetData("select pid from [user.coupon] where id=@0", order.couponid);



            //判断该代金券是不是别人送的
            int pid = ConvertHelper.ToInt32(coupon["pid"]);

            if (pid <= 0)
            {
                return;
            }

            //用户不可以自己给自己返现
            if (pid == user.id)
            {
                return;
            }

            //判断该笔订单是否已经返现
            object exists_cash_obj = dbh.ExecuteScalar <object>("select top 1 1 from [user.cash] where orderno=@0", order.orderno);
            bool   exists_cash     = ConvertHelper.ToInt32(exists_cash_obj) > 0;

            if (exists_cash)
            {
                return;
            }



            var config = dbh.GetData("select top 1 [userpercentLimitAmount],[userpercentAmount] from [sys.config] where [enabled]=1");


            int userpercentLimitAmount = Convert.ToInt32(config["userpercentLimitAmount"]);
            int userpercentAmount      = Convert.ToInt32(config["userpercentAmount"]);

            //订单金额小于最小返现金额
            if (order.amount < userpercentLimitAmount)
            {
                throw new Exception("订单金额小于最小返现金额");
                return;
            }


            //达到返现最低消费
            int percentamt = Convert.ToInt32((decimal)order.amount * ((decimal)userpercentAmount / 100m));

            if (percentamt <= 0)
            {
                throw new Exception("达到返现最低消费");
                return;
            }

            var now = DateTime.Now;


            var conn = dbh.GetConnection();

            System.Data.Common.DbTransaction tran = null;

            try
            {
                conn.Open();
                tran = conn.BeginTransaction();


                var amountCmd = dbh.CreateCommand();
                amountCmd.Connection  = conn;
                amountCmd.Transaction = tran;
                amountCmd.CommandText = "select top 1 amountNow,amountTotal from [user.cashnow] where userid=@userid";
                amountCmd.Parameters.Add(dbh.CreateParameter("@userid", pid));


                //查询流水
                int amountNow   = 0;
                int amountTotal = 0;
                using (var reader = amountCmd.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        amountNow   = reader.GetInt32(0);
                        amountTotal = reader.GetInt32(1);
                    }
                }


                int amountNext = amountNow + percentamt;
                var cmdExe     = dbh.CreateCommand();
                cmdExe.Transaction = tran;
                cmdExe.Connection  = conn;
                cmdExe.CommandText = "insert into [user.cash] ([userid],[orderno],[amount],[date],[datets],[amountNow],[amountPrev],[amountTotal],[type],[info]) values (@userid,@orderno,@amount,@date,@datets,@amountNow,@amountPrev,@amountTotal,@type,@info) select @@identity";

                cmdExe.Parameters.Add(dbh.CreateParameter("@userid", pid));
                cmdExe.Parameters.Add(dbh.CreateParameter("@orderno", order.orderno));
                cmdExe.Parameters.Add(dbh.CreateParameter("@amount", percentamt));
                cmdExe.Parameters.Add(dbh.CreateParameter("@date", now));
                cmdExe.Parameters.Add(dbh.CreateParameter("@datets", Common.Helpers.TimeHelper.GetTimeStamp(now, 10)));

                //amountNext, amountNow, amountTotal + percentamt
                cmdExe.Parameters.Add(dbh.CreateParameter("@amountNow", amountNext));
                cmdExe.Parameters.Add(dbh.CreateParameter("@amountPrev", amountNow));
                cmdExe.Parameters.Add(dbh.CreateParameter("@amountTotal", amountTotal + percentamt));
                cmdExe.Parameters.Add(dbh.CreateParameter("@type", "give"));
                cmdExe.Parameters.Add(dbh.CreateParameter("@info", "好友" + user.name + "到店消费"));
                object idobj = cmdExe.ExecuteScalar();

                int cashid = 0;

                if (idobj != null && idobj != DBNull.Value)
                {
                    cashid = Convert.ToInt32(idobj);
                }


                var cmdUpdate = dbh.CreateCommand();
                cmdUpdate.Transaction = tran;
                cmdUpdate.Connection  = conn;
                cmdUpdate.CommandText = "update [user.cashnow] set amountNow=@amountNow,amountPrev=@amountPrev,amountTotal=@amountTotal,[date]=@date where userid=@userid";

                cmdUpdate.Parameters.Add(dbh.CreateParameter("@userid", pid));
                cmdUpdate.Parameters.Add(dbh.CreateParameter("@amountNow", amountNext));
                cmdUpdate.Parameters.Add(dbh.CreateParameter("@amountPrev", amountNow));
                cmdUpdate.Parameters.Add(dbh.CreateParameter("@amountTotal", amountTotal + percentamt));
                cmdUpdate.Parameters.Add(dbh.CreateParameter("@date", now));

                int cmdUN = cmdUpdate.ExecuteNonQuery();
                if (cmdUN == 0)
                {
                    var cmdInsert = dbh.CreateCommand();
                    cmdInsert.Transaction = tran;
                    cmdInsert.Connection  = conn;
                    cmdInsert.CommandText = "insert into [user.cashnow] (userid,amountNow,amountPrev,amountTotal,[date]) values (@userid,@amountNow,@amountPrev,@amountTotal,@date)";

                    cmdInsert.Parameters.Add(dbh.CreateParameter("@userid", pid));
                    cmdInsert.Parameters.Add(dbh.CreateParameter("@amountNow", amountNext));
                    cmdInsert.Parameters.Add(dbh.CreateParameter("@amountPrev", amountNow));
                    cmdInsert.Parameters.Add(dbh.CreateParameter("@amountTotal", amountTotal + percentamt));
                    cmdInsert.Parameters.Add(dbh.CreateParameter("@date", now));

                    cmdInsert.ExecuteNonQuery();
                }


                tran.Commit();


                new Thread(() =>
                {
                    SendCashMessage(pid, cashid, percentamt, amountNow);
                }).Start();
            }
            catch (Exception e)
            {
                tran.Rollback();

                throw e;
            }
            finally
            {
                if (tran != null)
                {
                    tran.Dispose();
                }

                if (conn != null)
                {
                    if (conn.State == System.Data.ConnectionState.Open)
                    {
                        conn.Close();
                    }

                    conn.Dispose();
                }
            }



            //var cash = dbh.GetData("select top 1 amountNow,amountTotal from [user.cashnow] where userid=@0", pid);
            //if (cash != null)
            //{
            //    amountNow = Convert.ToInt32(cash["amountNow"]);
            //    amountTotal = Convert.ToInt32(cash["amountTotal"]);
            //}



            //var cashid = dbh.ExecuteScalar<int>("insert into [user.cash] ([userid],[orderno],[amount],[date],[datets],[amountNow],[amountPrev],[amountTotal],[type],[info]) values (@0,@1,@2,@3,@4,@5,@6,@7,@8,@9) select @@identity", pid, order.orderno, percentamt, DateTime.Now, Common.Helpers.TimeHelper.GetTimeStamp(DateTime.Now, 10), amountNext, amountNow, amountTotal + percentamt, "give", "好友" + user.name + "到店消费");

            //if (dbh.ExecuteNoneQuery("update [user.cashnow] set amountNow=@0,amountPrev=@1,amountTotal=@2,[date]=@3 where userid=@4", amountnext, amountNow, amountTotal + percentamt, DateTime.Now, pid) == 0)
            //{
            //    dbh.ExecuteNoneQuery("insert into [user.cashnow] (userid,amountNow,amountPrev,amountTotal,[date]) values (@0,@1,@2,@3,@4)", pid, amountnext, amountNow, amountTotal + percentamt, DateTime.Now);
            //}
        }
示例#12
0
        public void getTest()
        {
            var u = new Entities.UserInfo()
            {
                name       = "测试",
                department = new int[] { 1 },
                mobile     = "15111111111",
                extattr    = new Entities.UserInfo.Extattr
                {
                    attrs = new Entities.UserInfo.Extattr.NameValuePair[] {
                        new Entities.UserInfo.Extattr.NameValuePair {
                            name = "hello", value = "hi"
                        }
                    }
                }
            };


            var userid = DD.User.create(u);

            Assert.IsNotNull(userid);



            var user = DD.User.get(userid);

            Assert.IsNotNull(user);
            Assert.IsNotNull(user.extattr.attrs);
            Assert.IsTrue(user.extattr.attrs.Length > 0);
            Assert.AreEqual(user.extattr.attrs[0].value, "hi");
            Assert.AreEqual(user.name, "测试");



            user.email = "*****@*****.**";
            var isupdated = DD.User.update(user);

            Assert.IsTrue(isupdated);

            user = DD.User.get(userid);
            Assert.AreEqual(user.email, "*****@*****.**");

            var isdeleted = DD.User.delete(userid);

            Assert.IsTrue(isdeleted);



            string[] ids = new string[10];
            for (int i = 0; i < ids.Length; i++)
            {
                u = new Entities.UserInfo()
                {
                    name       = "测试" + i,
                    department = new int[] { 1 },
                    mobile     = "1511111112" + i,
                    extattr    = new Entities.UserInfo.Extattr
                    {
                        attrs = new Entities.UserInfo.Extattr.NameValuePair[] {
                            new Entities.UserInfo.Extattr.NameValuePair {
                                name = "hello", value = "hi"
                            }
                        }
                    }
                };
                userid = DD.User.create(u);
                Assert.IsNotNull(userid);
                ids[i] = userid;
            }


            isdeleted = DD.User.batchdelete(ids);
            Assert.IsTrue(isdeleted);
        }
示例#13
0
 public Task <int> UpdateUserInfoAsync(Entities.UserInfo userInfo)
 {
     return(Database.UpdateAsync(userInfo));
 }
示例#14
0
 public Task <int> CreateUserInfoAsync(Entities.UserInfo userInfo)
 {
     return(Database.InsertAsync(userInfo));
 }