Example #1
0
        /// <summary>
        /// 更新
        /// </summary>
        public void Update()
        {
            BackendContext db = new BackendContext();

            this.UpdateDate      = DateTime.Now;
            this.Updater         = System.Web.HttpContext.Current.User.Identity.Name;
            db.Entry(this).State = EntityState.Modified;
            db.SaveChanges();
        }
Example #2
0
        /// <summary>
        /// 新增
        /// </summary>
        public void Create(BackendContext db, System.Data.Entity.DbSet dbSet)
        {
            if (this.InitDate == null)
            {
                this.InitDate = DateTime.Now;
            }

            this.Poster = System.Web.HttpContext.Current.User.Identity.Name;
            dbSet.Add(this);
            db.SaveChanges();
        }
Example #3
0
        public bool AddMember()
        {
            BackendContext db = new BackendContext();

            var pid = new SqlParameter {
                ParameterName = "Id", Value = 0, Direction = ParameterDirection.Output
            };
            var result =
                db.Members.SqlQuery(
                    "dbo.CreateMember @Account,@Password,@PasswordSalt,@Name,@Email,@JobTitle,@Permission,@Poster,@UnitId,@Gender,@MyPic,@Id out",
                    new SqlParameter("Account", this.Account), new SqlParameter("Password", this.Password),
                    new SqlParameter("@PasswordSalt", this.PasswordSalt),
                    new SqlParameter("Name", this.Name),
                    new SqlParameter("Email", this.Email), new SqlParameter("JobTitle", this.JobTitle),
                    new SqlParameter("Permission", this.Permission),
                    new SqlParameter("Poster", "admin"), new SqlParameter("UnitId", this.UnitId),
                    new SqlParameter("Gender", this.Gender),
                    new SqlParameter("MyPic", this.MyPic ?? ""), pid).SingleOrDefault();

            return(pid.Value.ToString() != "0");
        }