public async Task <RulesetTileColor> Update(RulesetTileColor color)
        {
            var _tileColor = await _repo.Get(color.TileColorId);

            if (_tileColor == null)
            {
                return(_tileColor);
            }

            _tileColor.TitleBgColor   = color.TitleBgColor;
            _tileColor.TitleTextColor = color.TitleTextColor;
            _tileColor.BodyBgColor    = color.BodyBgColor;
            _tileColor.BodyTextColor  = color.BodyTextColor;
            _tileColor.RulesetTileId  = color.RulesetTileId;
            _tileColor.CreatedBy      = color.CreatedBy;
            _tileColor.CreatedDate    = DateTime.Now;

            try
            {
                await _repo.Update(_tileColor);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_tileColor);
        }
        public RulesetTileColor GetById(int id)
        {
            RulesetTileColor tileColor = _context.RulesetTileColors
                                         // .Include(d => d.CharacterTile).ThenInclude(y => y.Character)
                                         .Include(d => d.User)
                                         .Where(x => x.TileColorId == id && x.IsDeleted != true)
                                         .SingleOrDefault();

            return(tileColor);
        }
        public async Task <RulesetTileColor> Create(RulesetTileColor color)
        {
            try
            {
                var colorExist = _context.TileColors.Where(x => x.CreatedBy == color.CreatedBy &&
                                                           x.BodyTextColor == color.BodyTextColor && x.TitleTextColor == color.TitleTextColor).FirstOrDefault();

                if (colorExist != null)
                {
                    _context.TileColors.Remove(colorExist);
                }
            }
            catch { }

            color.IsDeleted   = false;
            color.CreatedDate = DateTime.Now;
            _context.Add(color);
            _context.SaveChanges();
            return(color);
        }