public LogInfo ToLogInfo(LogInfoEntity entity)
 {
     return(new LogInfo()
     {
         Id = entity.Id,
         Message = entity.Messagge,
         Date = entity.Date,
         LogType = entity.LogType,
         Username = entity.Username
     });
 }
示例#2
0
        public LogInfo Get(int id)
        {
            if (!Exists(id))
            {
                throw new LogNotFoundException();
            }

            LogInfoEntity logInDb = context.Logs.First(l => l.Id == id);

            return(mapper.ToLogInfo(logInDb));
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
        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));
        }