public void GetCompanyTest() { var environmentFactory = EnvironmentFactoryFactory.Create(); var company1Id = _companyService.Create("new company1"); var company2Id = _companyService.Create("new company2"); var incoming = new List <TelemetryDataSinkParametersDto> { new TelemetryDataSinkParametersDto { SinkName = "test", Parameters = new Dictionary <string, string> { { "k1", "v1" }, { "k2", "v2" } } } }; _companyService.UpdateIncomingTelemetryDataSinks(company1Id, incoming); var platformCompanyOperations = environmentFactory.ManagementEnvironment.ObjCompanyOperations; var c1 = platformCompanyOperations.Get(company1Id); var c2 = platformCompanyOperations.Get(company2Id); Assert.AreEqual(company1Id, c1.Id); Assert.AreEqual(1, c1.TelemetryDataSinkSettings.Incoming.Count()); Assert.AreEqual("test", c1.TelemetryDataSinkSettings.Incoming.First().SinkName); Assert.AreEqual(2, c1.TelemetryDataSinkSettings.Incoming.First().Parameters.Count); Assert.AreEqual(company2Id, c2.Id); Assert.IsNull(c2.TelemetryDataSinkSettings.Incoming); }
public void TestGetCompanyByCvr() { CompanyService service = new CompanyService(); Company company = new Company() { Name = "Company", Adress = "Adress22", ContactPerson = "Captain jack", Cvr = 23456789, Mail = "*****@*****.**", Phone = 12345678 }; service.Create(company); Company company2 = new Company() { Name = "Company2", Adress = "Adress22", ContactPerson = "Captain jack", Cvr = 12345678, Mail = "*****@*****.**", Phone = 12345678 }; service.Create(company2); Assert.AreEqual(service.Get(company2.Cvr).Name, "Company2"); }
public void TestDeleteCompany() { CompanyService service = new CompanyService(); Company company = new Company() { Name = "Company", Adress = "Adress22", ContactPerson = "Captain jack", Cvr = 23456789, Mail = "*****@*****.**", Phone = 12345678 }; service.Create(company); Company company2 = new Company() { Name = "Company2", Adress = "Adress22", ContactPerson = "Captain jack", Cvr = 12345678, Mail = "*****@*****.**", Phone = 12345678 }; service.Create(company2); service.Delete(company2.Cvr); Assert.IsFalse(service.GetAll().Exists(x => x.Name == company2.Name)); Assert.AreEqual(service.GetAll().Count, 1); }
public void TryCreateDeviceUnderOtherNetworkTest() { var environmentFactory = EnvironmentFactoryFactory.Create(); var authenticationContext = Substitute.For <IAuthenticationContext>(); var messagingService = Substitute.For <IMessagingServiceClient>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, authenticationContext, settingProvider, null); var userId1 = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); var companyService = new CompanyService(companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider)); authenticationContext.GetContextUser().Returns(userId1); var companyId1 = companyService.Create("new company1"); var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations; var serviceService = new ServiceService(serviceOperations, companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider)); var serviceId1 = serviceService.Create(new ServiceDto() { CompanyId = companyId1, Name = "svc" }); var companyId2 = companyService.Create("new company2"); var serviceId2 = serviceService.Create(new ServiceDto() { CompanyId = companyId2, Name = "svc" }); var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations; var networkService = new NetworkService(networkOperations, serviceOperations, companyOperations, authenticationContext, null); var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations; var deviceService = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations, authenticationContext, messagingService); var networkId2 = networkService.Create(new NetworkDto() { ServiceId = serviceId2, CompanyId = companyId2, Name = "svc" }); var device = new DeviceDto() { NetworkId = networkId2, CompanyId = companyId1, ServiceId = serviceId1, Name = "test" }; deviceService.Create(device); }
public void ListCompaniesTest() { var environmentFactory = EnvironmentFactoryFactory.Create(); var authenticationContext = Substitute.For <IAuthenticationContext>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, authenticationContext, settingProvider, null); var userId = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); var companyService = new CompanyService(companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider)); authenticationContext.GetContextUser().Returns(userId); var compId = companyService.Create("new company"); var companies = userService.ListCompanies(); Assert.AreEqual(1, companies.Count); Assert.AreEqual(compId, companies[0].Id); }
private void Initialize() { var environmentFactory = EnvironmentFactoryFactory.Create(); _authenticationContext = Substitute.For <IAuthenticationContext>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; _companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, _authenticationContext, settingProvider, null); _userId = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); _companyService = new CompanyService(_companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _authenticationContext.GetContextUser().Returns(_userId); _companyId = _companyService.Create("new company"); _serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations; _serviceService = new ServiceService(_serviceOperations, _companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _serviceId = _serviceService.Create(new ServiceDto() { CompanyId = _companyId, Name = "new service" }); _networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations; _networkService = new NetworkService(_networkOperations, _serviceOperations, _companyOperations, _authenticationContext, null); }
public string CreateCompany([FromBody] JObject companyJObject) { var message = string.Empty; if (!CompanyValidator.Validate(companyJObject, out message)) { return(message); } string isin = companyJObject["Isin"].ToObject <string>(); // return if Isin already exists if (_companyService.GetCompanyByIsin(isin) != null) { return("ISIN already exists"); } string name = companyJObject["Name"].ToObject <string>(); string stock = companyJObject["StockTicker"].ToObject <string>(); string exchange = companyJObject["Exchange"].ToObject <string>(); string website = companyJObject["Website"].ToObject <string>() ?? string.Empty; var company = new Company(isin, name, stock, exchange, website); _companyService.Create(company); return($"{company.Isin}: Successfully created"); }
public async Task CreateCompanyShouldSaveCorrectData() { // Arrange var db = this.GetDatabase(); const int Id = 1; const string Name = "Star Sechko"; const string Information = "Some company information."; var companyService = new CompanyService(db); var model = new CompanyRequestModel { Id = 1, Name = Name, Founded = DateTime.MaxValue, Information = Information, }; // Act await companyService.Create(model); var result = await db.Companys.FindAsync(Id); // Assert Assert.Equal(Id, result.Id); Assert.Equal(Name, result.Name); Assert.Equal(Information, result.Information); }
public void TryCreateServiceUnderOthersCompanyTest() { var environmentFactory = EnvironmentFactoryFactory.Create(); var authenticationContext = Substitute.For <IAuthenticationContext>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, authenticationContext, settingProvider, null); var userId1 = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); var userId2 = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); var companyService = new CompanyService(companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider)); authenticationContext.GetContextUser().Returns(userId1); var companyId1 = companyService.Create("new company1"); authenticationContext.GetContextUser().Returns(userId2); var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations; var serviceService = new ServiceService(serviceOperations, companyOperations, authenticationContext, null, new CapabilityProvider(settingProvider)); serviceService.Create(new ServiceDto() { CompanyId = companyId1, Name = "svc" }); }
protected void Initialize() { var environmentFactory = EnvironmentFactoryFactory.Create(); _authenticationContext = Substitute.For <IAuthenticationContext>(); var messagingServiceClient = Substitute.For <IMessagingServiceClient>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, _authenticationContext, settingProvider, null); _userId = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); _companyService = new CompanyService(companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _authenticationContext.GetContextUser().Returns(_userId); _companyId = _companyService.Create("new company"); var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations; _serviceService = new ServiceService(serviceOperations, companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _serviceId = _serviceService.Create(new ServiceDto() { CompanyId = _companyId, Name = "new service" }); var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations; var telemetryDataSinkSetupServiceClient = Substitute.For <ITelemetryDataSinkSetupServiceClient>(); telemetryDataSinkSetupServiceClient.GetTelemetryDataSinksMetadata().Returns( new TelemetryDataSinksMetadataDtoClient { Incoming = new List <TelemetryDataSinkMetadataDtoClient> { new TelemetryDataSinkMetadataDtoClient { Name = "test", Description = null, ParametersToInput = new List <string> { "k1", "k2" } } } }); _networkService = new NetworkService(networkOperations, serviceOperations, companyOperations, _authenticationContext, telemetryDataSinkSetupServiceClient); messagingServiceClient.Initialize("1234").ReturnsForAnyArgs(1); var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations; _deviceService = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations, _authenticationContext, messagingServiceClient); }
/// <summary> /// 添加公司-保存 /// </summary> /// <param name="company"></param> /// <param name="user"></param> /// <param name="BuninessType"></param> /// <returns></returns> public JsonResult Save(CompanyModel company, UserModel user, List <string> BuninessType) { return(ExceptionCatch.Invoke(() => { user.Password = CryptTools.Md5(user.Password); CompanyService.Create(company, user, BuninessType); })); }
public async Task Create(CompanyDto employee) { using (UnitOfWorkProvider.Create()) { _companyService.Create(employee); await UnitOfWorkProvider.GetUnitOfWorkInstance().Commit(); } }
public static void Insert(IEnumerable <CompanyViewModel> companies) { CompanyService companyService = new CompanyService(new DBModel()); foreach (var company in companies) { companyService.Create(company); } }
public void Test_CreateCompany() { ICompanyService service = new CompanyService(Settings.Default.connString); Company cpy1 = new Company() { name = "中国电信", remark = "电信公司", address = "上海浦东" }; Assert.IsTrue(service.Create(cpy1)); Company cpy2 = new Company() { name = "中国移动", remark = "移动公司", address = "上海浦东" }; Assert.IsTrue(service.Create(cpy2)); }
private void Initialize() { var environmentFactory = EnvironmentFactoryFactory.Create(); _authenticationContext = Substitute.For <IAuthenticationContext>(); _messagingServiceClient = Substitute.For <IMessagingServiceClient>(); var userOperations = environmentFactory.ManagementEnvironment.MgmtUserOperations; var companyOperations = environmentFactory.ManagementEnvironment.MgmtCompanyOperations; var settingProvider = new SettingProvider(environmentFactory.ManagementEnvironment.MgmtSettingOperations); var userService = new UserService(userOperations, _authenticationContext, settingProvider, null); _userId = userService.Register(new RegisterDto() { Name = "user", Email = EmailHelper.Generate(), Password = "******" }, null); _companyService = new CompanyService(companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _authenticationContext.GetContextUser().Returns(_userId); _companyId = _companyService.Create("new company"); var serviceOperations = environmentFactory.ManagementEnvironment.MgmtServiceOperations; _serviceService = new ServiceService(serviceOperations, companyOperations, _authenticationContext, null, new CapabilityProvider(settingProvider)); _serviceId = _serviceService.Create(new ServiceDto() { CompanyId = _companyId, Name = "new service" }); var networkOperations = environmentFactory.ManagementEnvironment.MgmtNetworkOperations; _networkService = new NetworkService(networkOperations, serviceOperations, companyOperations, _authenticationContext, null); var network = new NetworkDto() { Name = "new network", ParentNetworkId = null, CompanyId = _companyId, ServiceId = _serviceId }; _networkId = _networkService.Create(network); _messagingServiceClient.Initialize("1234").ReturnsForAnyArgs(1); var deviceOperations = environmentFactory.ManagementEnvironment.MgmtDeviceOperations; _deviceService = new DeviceService(deviceOperations, networkOperations, serviceOperations, companyOperations, _authenticationContext, _messagingServiceClient); }
public IHttpActionResult Post([FromBody] Contracts.Company.CreateCompany create) { var result = CompanyService.Create(create); UploadedImage uploadedImage; if (UploadStore.UserImages.TryGetValue(UserId, out uploadedImage) && uploadedImage != null) { CompanyService.UpdateProfileImage(result.CompanyId, uploadedImage.Image, uploadedImage.ContentType); UploadStore.UserImages.TryRemove(UserId, out uploadedImage); } return(Ok(result)); }
public IActionResult Post(CompanyCreateRequestModel model) { try { var result = _service.Create(model); if (result == null) { return(BadRequest(model)); } return(Ok(result)); } catch (Exception e) { try { _logService.SendLogError(e); } catch (System.Exception ex) { return(StatusCode(503, ex)); } return(StatusCode(503, e)); } }
public ActionResult Create([Bind(Include = "Name, remark, address")] Company company) { try { // TODO: Add insert logic here ICompanyService cs = new CompanyService(Settings.Default.db); cs.Create(company); return(RedirectToAction("Index")); } catch { return(View()); } }
public void TestGetAllCompanies() { CompanyService service = new CompanyService(); Company company = new Company() { Name = "Company", Adress = "Adress22", ContactPerson = "Captain jack", Cvr = 12345678, Mail = "*****@*****.**", Phone = 12345678 }; service.Create(company); List <Company> companies = service.GetAll(); Assert.AreEqual(service.GetAll().Count, 1); }
public void CreateCompany() { var userService = new UserService(); var companyService = new CompanyService(userService); var company = companyService.Create( new CreateCompany() { Name = "TestCompany" } ); //Cleanup companyService.Delete(company.CompanyId); using (var db = new RAAPMasterEntities()) { using (var sqlConnection = new SqlConnection(db.Database.Connection.ConnectionString)) { sqlConnection.Open(); var sqlCommand = new SqlCommand("drop database TestCompany", sqlConnection); sqlCommand.ExecuteNonQuery(); } } }
public IHttpActionResult Create([FromBody] CompanyRequest companyToCreate) { if (companyToCreate == null) { return(BadRequest("Empty request body!")); } if (!ModelState.IsValid) { return(BadRequest(ControllerHelper.GetModelStateErrorMessages(ModelState))); } var temp = _companyService.GetByName(companyToCreate.Name); if (temp != null) { return(BadRequest("A company with that name already exists!")); } var result = _companyService.Create(companyToCreate); return(Ok(result)); }
public IActionResult Register([FromBody] RegistrationDto userDto) { Console.WriteLine("Reg"); if (userDto.company == null || userDto.company.AddressId == 0) { return(BadRequest()); } if (userDto.user == null || userDto.user.Email == "") { return(BadRequest()); } CompanyService cs = new CompanyService(); var regCompany = _mapper.Map <Companies>(userDto.company); try { Console.WriteLine("Register company!"); cs.Create(regCompany); } catch (AppException ex) { return(BadRequest(ex.Message)); } userDto.user.CompanyId = regCompany.IdCompany; var regUser = _mapper.Map <Users>(userDto.user); try { Console.WriteLine("Register user!"); _userService.Create(regUser, userDto.user.Pass); return(Ok()); } catch (AppException ex) { return(BadRequest(ex.Message)); } }
public ActionResult <Company> Create([FromBody] Company company) { _companyService.Create(company); return(CreatedAtRoute("GetCompany", new { id = company.Id.ToString() }, company)); }
public void Post([FromBody] Company value) { var service = new CompanyService(); bool result = service.Create(value); }
public IActionResult Get() { try { // string tempToken = "EAADcf5Tn8Q0BAA6DdKIRm8vQ1TuZCJA93pA893nGyZAabOsyNPJl7psqiEBZBtrrV318UBjecemc2quU3OkMQH8YGV6tR12tvZBMUzWaLuDWoell68ZB5YB0cWuvq0Phh5vFyS6av3vLqZCRR69Bdjhye05Ofs5zaI3sgfasd1Ukfkeg6LPbmuvBKtiGldx7kZD"; // Seed Data string pass = Utility.ParseEInfo("DevS@b3r", _appSettings.General.SysInfo); string tok = Utility.ParseEInfo("EAADcf5Tn8Q0BAPqlinfwZAQ6JrcAdvq5OdpxHlFZCw4anCRga5CEq0jKipw2iEgwzADIMmAftoGloGpYiwlsa2YDaeMBRM1NCApN4XSZAbEovKiESVB5TQZBHClzs13voVQZBffPRZB5gZA3ixnZAUZCa2Bm87HJzNuKvvzrt1HcdJ9WO6ygKOq28qVzQMTWTJsUZD", _appSettings.General.SysInfo); var companyResult = _companyService.Create(new Company { CompanyName = "Sabre", FbPageId = "102327571503111", FbPageToken = tok, TicketSysUrl = "http://58.185.112.2:8550", TicketSysId = "*****@*****.**", TicketSysPassword = pass, contactEmail = "*****@*****.**" }); //if (companyResult != null) //{ // var clientCompanyResult = _clientCompanyService.Create(new ClientCompany { ClientCompanyName = "ZZTEST", TicketSysCompanyCode = "124", VerificationEmail = "*****@*****.**", VerificationCode = "123456" }); // _jiraUserMgmtService.Create(new JiraUser { UserFbId = "3058942664196267", CompanyId = companyResult.Id, ClientCompanyId = clientCompanyResult.Id, UserNickname = "abc nickname" }); //} //JObject message = JObject.FromObject(new //{ // recipient = new { id = "3419843058061019" }, // message = new // { // attachment = new // { // type = "template", // payload = new // { // template_type = "one_time_notif_req", // title = "Do you want to get notified with [ABC-001] updates?", // payload = string.Format(FacebookCustomPayload.CASE_GET_NOTIFIED_PAYLOAD, "[ABC-001]") // } // } // } //}); //_fbApiClientService.PostMessageAsync(tempToken, message); //JObject message = JObject.FromObject(new //{ // recipient = new { one_time_notif_token = "6543617655184695474" }, // message = new // { // text = "Follow up:\n\n[ABC-001] updated to Completed" // } //}); //_fbApiClientService.PostMessageAsync(tempToken, message); //var errMsg = JObject.FromObject(new //{ // recipient = new { one_time_notif_token = "7915953949996185142" }, // message = new { text = $"Test Repeating Blast" } //}); //await _fbApiClientService.PostMessageAsync("EAADcf5Tn8Q0BAA6DdKIRm8vQ1TuZCJA93pA893nGyZAabOsyNPJl7psqiEBZBtrrV318UBjecemc2quU3OkMQH8YGV6tR12tvZBMUzWaLuDWoell68ZB5YB0cWuvq0Phh5vFyS6av3vLqZCRR69Bdjhye05Ofs5zaI3sgfasd1Ukfkeg6LPbmuvBKtiGldx7kZD", errMsg); return(Ok("Seed Complete.")); } catch (Exception ex) { LoggingHelper.LogError(ex, _logger, this.Request, this.RouteData); return(StatusCode(500)); } }
public void CreateCompanyTest() { var id = _companyService.Create("new company"); Assert.AreEqual(32, id.Length); }
public ActionResult <Company> Post([FromBody] Company company) { service.Create(company); return(CreatedAtRoute(RouteConstants.GetCompanies, new { id = company.Id.ToString() }, company)); }
public ActionResult <Empresa> Create(Empresa company) { _companyService.Create(company); return(CreatedAtRoute("GetCompany", new { id = company.Id }, company)); }
public ActionResult <Company> Create(Company company) { _companySerivce.Create(company); return(CreatedAtRoute("GetCompany", new { id = company.Id }, company)); }
public ActionResult <CompanyProfileViewModel> Create([FromBody] CompanyProfileViewModel model) { var company = _companyService.Create(model); return(CreatedAtRoute("GetCompany", new { id = company.Id.ToString() }, model)); }