Ejemplo n.º 1
0
        /// <summary>
        /// Persists a linked resource
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public LinkedResourceDto Save(LinkedResourceDto dto)
        {
            try
            {
                var entity = new LinkedResource();

                if (dto.Id > 0)
                {
                    entity = _dbContext.LinkedResources.SingleOrDefault(x => x.UID == dto.Id);
                }
                else
                {
                    _dbContext.LinkedResources.Add(entity);
                }

                // Commit
                Mappings.Map(ref entity, dto);
                _dbContext.SaveChanges();

                return(Mappings.Map(entity));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public static LyncNinjaContext InitialiseLyncNinjaContext()
        {
            var options = new DbContextOptionsBuilder <LyncNinjaContext>()
                          .UseLazyLoadingProxies()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new LyncNinjaContext(options);

            context.AddRange(DbSets.LinkedResources);
            context.SaveChanges();

            return(context);
        }