void ITimeZoneService.Create(TimeZone timeZone) { if (_repository.FindByName(timeZone.Name) != null) { throw new InvalidOperationException("已经存在同名的时区信息"); } _repository.Add(timeZone); }
public int CreateTimeZone(string name) { using (IUnitOfWork work = UnitOfWork.Begin()) { TimeZone timeZone = DomainObjectFactory.CreateTimeZone(); timeZone.Name = name; timeZone.IsActive = true; timeZone.IsDeleted = false; _timeZoneRepository.Add(timeZone); work.Commit(); var message = new XElement(XMLLogLiterals.LOG_MESSAGE); message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageTimeZoneCreated", new List <string> { timeZone.Name })); _logService.CreateLog(CurrentUser.Get().Id, "web", CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, message.ToString()); return(timeZone.Id); } }