Пример #1
0
        public SaveResult InsertOrUpdate(ref LogVIPDTO log)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    long logId = log.LogId;
                    LogChat entity = context.LogChat.FirstOrDefault(c => c.LogId.Equals(logId));

                    if (entity == null)
                    {
                        log = Insert(log, context);
                        return SaveResult.Inserted;
                    }

                    log.LogId = entity.LogId;
                    log = Update(entity, log, context);
                    return SaveResult.Updated;
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return SaveResult.Error;
            }
        }
Пример #2
0
 private LogVIPDTO Update(LogChat entity, LogVIPDTO respawn, OpenNosContext context)
 {
     if (entity == null)
     {
         return(null);
     }
     _mapper.Map(respawn, entity);
     context.SaveChanges();
     return(_mapper.Map <LogVIPDTO>(entity));
 }