Beispiel #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;
            }
        }
 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));
 }