예제 #1
0
        public bool Modify(Result t)
        {
            Result entity = _context.Results.Where(e => e.Id == t.Id).FirstOrDefault();

            if (entity == null)
            {
                return(false);
            }

            EntityEntry entry = _context.Entry(entity);

            entry.CurrentValues.SetValues(t);
            _context.SaveChanges();

            return(true);
        }
예제 #2
0
        public bool Remove(int memberId, int roleId)
        {
            MemberRole entity = _context.MemberRole.FromSqlRaw($"SELECT * FROM MemberRole WHERE MemberId = {memberId} AND RoleId = {roleId} AND EndDate = '9999-1-1'").FirstOrDefault();

            if (entity == null)
            {
                return(false);
            }

            MemberRole removedMemberRole = _context.MemberRole.FromSqlRaw($"SELECT * FROM MemberRole WHERE MemberId = {memberId} AND RoleId = {roleId} AND EndDate = '9999-1-1'").FirstOrDefault();

            removedMemberRole.EndDate = DateTime.Today;

            EntityEntry entry = _context.Entry(entity);

            entry.CurrentValues.SetValues(removedMemberRole);
            _context.SaveChanges();

            return(true);
        }