public async Task <IHttpActionResult> UpdateDictionaryServiceType(int id, DictionaryServiceType entity)
        {
            var existingEntity = await context.DictionaryServiceTypes.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 <DictionaryServiceType>().Local.FirstOrDefault(f => f.Id == entity.Id);

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

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

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

            var newEntity = new DictionaryServiceType()
            {
                SidClientId     = entity.SidClientId,
                SidCardTypeId   = entity.SidCardTypeId,
                ServiceTypeId   = entity.ServiceTypeId,
                ServiceCodeName = entity.ServiceCodeName
            };

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

            return(Ok <DictionaryServiceType>(newEntity));
        }
Exemple #3
0
 /// <summary>
 /// Returns the dictionary service instance.
 /// </summary>
 /// <param name="type">Type of the service provider.</param>
 /// <returns>Dictinary service instance.</returns>
 public static IDictionaryService Create(DictionaryServiceType type) =>
 type switch
 {