Beispiel #1
0
        public Priority Convert(string source, Priority destination, ResolutionContext context)
        {
            return(Task.Run(async() => {
                var priority = await _repository.FindByLevel(source);
                if (priority == null)
                {
                    _repository.Add(new Priority {
                        Level = source
                    });

                    if (!await _repository.SaveAll())
                    {
                        throw new ApplicationException("Something went wrong saving a new priority level to the database.");
                    }
                }
                return await _repository.FindByLevel(source);
            }).Result);
        }