public Admin Add(Admin entity)
        {
            var dbentity = _mapper.Map <DbShortUrl>(entity);

            _context.Add(dbentity);
            _context.SaveChanges();
            return(_mapper.Map <Admin>(dbentity));
        }
        public Visitor Add(Domain.Models.Visitor entity)
        {
            var dbentity = _mapper.Map <DbVisitor>(entity);

            _context.Add(dbentity);
            _context.SaveChanges();
            return(_mapper.Map <Visitor>(dbentity));
        }
Esempio n. 3
0
        public Stat Add(Domain.Models.Stat entity)
        {
            var entitystring = JsonConvert.SerializeObject(entity);

            _loggerservice.LogInformation("Adding new Stat to repository : " + entitystring);
            try
            {
                var dbentity = _mapper.Map <DbStat>(entity);
                _context.Add(dbentity);
                _context.Attach(dbentity.shortUrl);
                _context.SaveChanges();
                _loggerservice.LogInformation("Added new Stat to repository : " + entitystring);
                return(_mapper.Map <Domain.Models.Stat>(dbentity));
            }
            catch (Exception ex)
            {
                throw new RepositoryException("Error adding new Stat into repository. " + entitystring + " " + ex.Message);
            }
        }