public async Task <IHttpActionResult> UpdateDictionaryClientNames(int id, DictionaryClientName entity)
        {
            var existingEntity = await context.DictionaryClientNames.FindAsync(entity.Id);

            if (id != entity.Id)
            {
                return(BadRequest(ModelState));
            }

            if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached)
            {
                context.Entry(existingEntity).State = EntityState.Detached;
            }
            var local = context.Set <DictionaryClientName>().Local.FirstOrDefault(f => f.Id == entity.Id);

            if (local != null)
            {
                context.Entry(local).State = EntityState.Detached;
            }

            context.DictionaryClientNames.Attach(entity);
            context.Entry(entity).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(Ok <DictionaryClientName>(entity));
        }
        public async Task <IHttpActionResult> CreateDictionaryClientNames(DictionaryClientName entity)
        {
            string userId = User.Identity.GetUserId();

            var newEntity = new DictionaryClientName()
            {
                SidClientId    = entity.SidClientId,
                ClientCodeName = entity.ClientCodeName
            };

            context.DictionaryClientNames.Add(newEntity);
            await context.SaveChangesAsync();

            return(Ok <DictionaryClientName>(newEntity));
        }