public Stat Update(Domain.Models.Stat entity) { try { var stat = _mapper.Map <DbStat>(entity); _context.Stats .Add(stat); _context.SaveChanges(); return(_mapper.Map <Domain.Models.Stat>(stat)); } catch (Exception ex) { throw new RepositoryException("Error updating Stat from repository. " + ex.Message); } }
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); } }