Beispiel #1
0
        public async Task Set <T>(T item, int id) where T : class
        {
            T output = await context.Set <T>().FindAsync(id);

            if (output != null)
            {
                try
                {
                    context.Entry(output).CurrentValues.SetValues(item);

                    await context.SaveChangesAsync();
                }
                catch (Exception E)
                {
                    throw new Exception("400",
                                        new Exception($"New item is invalid: {E.Message}"));
                }
            }
            else
            {
                throw new Exception("500",
                                    new Exception("querried item does not exist"));
            }
        }