public virtual void Add(List <AddOptionLogDto> list) { try { var userInfo = SessionUtils.UserInfo; if (userInfo != null && userInfo.Id > 0 && list != null && list.Count > 0) { List <OptionLogDto> addlist = new List <OptionLogDto>(list.Count); foreach (var s in list) { OptionLogDto vm = new OptionLogDto() { Type = (int)s.Type, UserId = userInfo.Id, UserAccount = userInfo.Account, UserName = userInfo.Name, Address = userInfo.ClientAddress, CreateTime = DateTime.Now, Msg = s.Msg ?? "" }; addlist.Add(vm); } var optionLogRepository = this.GetRepository <IOptionLogRepository>(); optionLogRepository.Add(addlist); } } catch (Exception ex) { LogUtils.Error("【OptionLogService.Add】", ex); } }
public virtual void Add(OptionLogType type, string msg) { try { var userInfo = SessionUtils.UserInfo; if (userInfo != null && userInfo.Id > 0) { OptionLogDto vm = new OptionLogDto() { Type = (int)type, UserId = userInfo.Id, UserAccount = userInfo.Account, UserName = userInfo.Name, Address = userInfo.ClientAddress, CreateTime = DateTime.Now, Msg = msg ?? "" }; var optionLogRepository = this.GetRepository <IOptionLogRepository>(); optionLogRepository.Add(vm); } } catch (Exception ex) { LogUtils.Error("【OptionLogService.Add】", ex); } }
public virtual int Add(OptionLogDto vm) { int count = 0; if (vm != null) { using (var db = this.CreateDbContext()) { using (db.BeginTransaction()) { count += this.Add(vm, db); db.Commit(); } } } return(count); }
protected virtual int Add(OptionLogDto vm, FileContext db) { int count = 0; if (vm != null) { OptionLog m = new OptionLog() { Type = vm.Type, UserId = vm.UserId, UserAccount = vm.UserAccount, UserName = vm.UserName, Address = vm.Address, CreateTime = vm.CreateTime, Msg = vm.Msg ?? "" }; db.OptionLog.Add(m); count += db.SaveChanges(); vm.Id = m.Id; } return(count); }