public void Create(Setting setting) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { unitOfWork.GetSettingRepository().Create(setting); unitOfWork.Commit(); } }
public string Create(Device device) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { var deviceIdentity = Identity.NextIncremental(); device.Id = deviceIdentity; device.Company = unitOfWork.GetCompanyRepository().Get(device.Company.Id); device.Service = unitOfWork.GetServiceRepository().Get(device.Service.Id); device.Network = unitOfWork.GetNetworkRepository().Get(device.Network.Id); unitOfWork.GetDeviceRepository().Create(device); unitOfWork.Commit(); return(deviceIdentity); } }
public string Create(Service service) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { var serviceIdentity = Identity.NextIncremental(); service.Id = serviceIdentity; service.Networks = null; service.Company = unitOfWork.GetCompanyRepository().Get(service.Company.Id); service.TelemetryDataSinkSettings = new TelemetryDataSinkSettings(); unitOfWork.GetServiceRepository().Create(service); unitOfWork.Commit(); return(serviceIdentity); } }
public string Create(Company company, string userId) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { var user = unitOfWork.GetUserRepository().Get(userId); var companyIdentity = Identity.NextIncremental(); company.Id = companyIdentity; company.Services = null; company.TelemetryDataSinkSettings = new TelemetryDataSinkSettings(); var userCompany = new UserCompany { CompanyId = companyIdentity, UserId = user.Id }; unitOfWork.GetCompanyRepository().Create(company); unitOfWork.GetUserCompanyRepository().Create(userCompany); unitOfWork.Commit(); return(companyIdentity); } }
public string Create(User user, string passwordHash, string salt) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { var userIdentity = Identity.NextIncremental(); user.Id = userIdentity; unitOfWork.GetUserRepository().Create(user); var loginUser = new LoginUser { Email = user.Email, PasswordHash = passwordHash, Salt = salt, UserId = userIdentity }; unitOfWork.GetLoginUserRepository().Create(loginUser); unitOfWork.Commit(); return(userIdentity); } }
public string Create(Network network) { using (var unitOfWork = _managementUnitOfWorkFactory.Create()) { var networkIdentity = Identity.NextIncremental(); network.Id = networkIdentity; network.ChildNetworks = null; network.Company = unitOfWork.GetCompanyRepository().Get(network.Company.Id); network.Service = unitOfWork.GetServiceRepository().Get(network.Service.Id); network.ParentNetwork = network.ParentNetwork != null?unitOfWork.GetNetworkRepository().Get(network.ParentNetwork.Id) : null; network.TelemetryDataSinkSettings = new TelemetryDataSinkSettings(); unitOfWork.GetNetworkRepository().Create(network); unitOfWork.Commit(); return(networkIdentity); } }