Beispiel #1
0
        public LogModel Add(LogModel item)
        {
            LogModel logModel;

            using (var db = new LogDb())
            {
                var entity = new LogInfo()
                {
                    UserCode   = item.UserCode,
                    UserName   = item.UserName,
                    LoginIP    = item.LoginIP,
                    LogType    = (LogType)item.Type,
                    Operation  = item.Operation,
                    Remark     = item.Remark,
                    CreateDate = item.CreateDate
                };
                db.LogInfos.Add(entity);
                var result = db.SaveChanges();
                if (result > 0)
                {
                    logModel    = item;
                    logModel.Id = entity.Id;
                }
                else
                {
                    logModel = null;
                }
            }

            return(logModel);
        }