Beispiel #1
0
        public ManagerComment Edit(ManagerComment entity)
        {
            using (var db = new Entities())
            {
                if (!string.IsNullOrWhiteSpace(entity.Content))
                {
                    entity.ModifyDate = DateTime.Now;
                    entity.ModifyUserID = CurrentUserBiz.CurrentUser.ID;

                    entity.UserID = CurrentUserBiz.CurrentUser.ID;
                    entity.UserName = CurrentUserBiz.CurrentUser.UserName;

                    var entry = db.Entry(entity);
                    entry.State = EntityState.Unchanged;
                    entry.Property(q => q.Content).IsModified = true;
                    entry.Property(q => q.ModifyDate).IsModified = true;
                    entry.Property(q => q.ModifyUserID).IsModified = true;
                    entry.Property(q => q.UserID).IsModified = true;
                    entry.Property(q => q.UserName).IsModified = true;

                    Errors = db.GetErrors();
                    if (!HasError)
                    {
                        db.SaveChanges();
                    }
                }
                return entity;
            }
        }
Beispiel #2
0
        public ManagerComment Add(ManagerComment entity)
        {
            using (var db = new Entities())
            {
                if (!string.IsNullOrWhiteSpace(entity.Content))
                {
                    entity.CreateDate = DateTime.Now;
                    entity.CreateUserID = CurrentUserBiz.CurrentUser.ID;
                    entity.ModifyDate = DateTime.Now;
                    entity.ModifyUserID = CurrentUserBiz.CurrentUser.ID;

                    entity.UserID = CurrentUserBiz.CurrentUser.ID;
                    entity.UserName = CurrentUserBiz.CurrentUser.UserName;

                    db.ManagerComment.Add(entity);
                    Errors = db.GetErrors();
                    if (!HasError)
                    {
                        db.SaveChanges();
                    }
                }
                return entity;
            }
        }