public LogInfo ToLogInfo(LogInfoEntity entity) { return(new LogInfo() { Id = entity.Id, Message = entity.Messagge, Date = entity.Date, LogType = entity.LogType, Username = entity.Username }); }
public LogInfo Get(int id) { if (!Exists(id)) { throw new LogNotFoundException(); } LogInfoEntity logInDb = context.Logs.First(l => l.Id == id); return(mapper.ToLogInfo(logInDb)); }
public void Delete(int id) { if (!Exists(id)) { throw new LogNotFoundException(); } LogInfoEntity logInDb = context.Logs.First(l => l.Id == id); context.Logs.Remove(logInDb); context.SaveChanges(); }
public void Modify(LogInfo entity) { if (!Exists(entity.Id)) { throw new LogNotFoundException(); } LogInfoEntity modified = mapper.ToEntity(entity); context.Entry(modified).State = EntityState.Modified; context.SaveChanges(); }
public LogInfo Add(LogInfo log) { if (Exists(log.Id)) { throw new LogAlreadyExistsException(); } LogInfoEntity entity = mapper.ToEntity(log); context.Entry(entity).State = EntityState.Added; context.SaveChanges(); return(mapper.ToLogInfo(entity)); }