Esempio n. 1
0
        public async Task <IActionResult> PutFeatureFlag(long id, FeatureFlag featureFlag)
        {
            if (id != featureFlag.FeatureId)
            {
                return(BadRequest());
            }

            _context.Entry(featureFlag).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeatureFlagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        protected virtual async Task <bool> Update(TModel model)
        {
            if (model.Id <= 0)
            {
                throw new ArgumentException("Invalid Id");
            }

            context.Entry(model).State = EntityState.Modified;

            try
            {
                await Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!await Exists(model.Id))
                {
                    throw new MissingMemberException($"{typeof(TModel).Name} doesn't exist");
                }
                throw;
            }

            return(true);
        }