public void CreateSampleOrganizationAndProject(string userId) { if (_projectRepository.GetByApiKey(SAMPLE_API_KEY) != null) { return; } User user = _userRepository.GetById(userId, true); var organization = new Organization { Id = "537650f3b77efe23a47914f3", Name = "Acme" }; _billingManager.ApplyBillingPlan(organization, BillingManager.UnlimitedPlan, user); organization = _organizationRepository.Add(organization); var project = new Project { Id = "537650f3b77efe23a47914f4", Name = "Disintegrating Pistol", TimeZone = TimeZone.CurrentTimeZone.StandardName, OrganizationId = organization.Id }; project.NextSummaryEndOfDayTicks = TimeZoneInfo.ConvertTime(DateTime.Today.AddDays(1), project.DefaultTimeZone()).ToUniversalTime().Ticks; project.ApiKeys.Add(SAMPLE_API_KEY); project.Configuration.Settings.Add("IncludeConditionalData", "true"); project.AddDefaultOwnerNotificationSettings(userId); project = _projectRepository.Add(project); _organizationRepository.IncrementStats(project.OrganizationId, projectCount: 1); user.OrganizationIds.Add(organization.Id); _userRepository.Save(user); }
public async Task <Guid> HandleCommand(AddOrganizationCommand cmd) { //lookup the StateProvince var state = _stateProvinceRepository.Get(cmd.StateProvinceId); if (state == null) { throw new FormatException("Submitted State/Province is invalid."); } //lookup the OrgType var orgType = _orgTypeRepository.Get(cmd.OrgTypeId); if (orgType == null) { throw new FormatException("Invalid Organization type submitted."); } //set the address var address = new Address(cmd.Address1, cmd.Address2, cmd.City, state, cmd.PostalCode, cmd.AddressType); var org = new Organization(cmd.Name, cmd.DbaName, cmd.EIN, address, orgType, cmd.ParentId, cmd.Active, cmd.Verified); _organizationRepository.Add(org); _organizationRepository.Save(); //fire event here await FireOrgAddedEvent(org, cmd); return(org.ID); }
private void CreateData() { foreach (Organization organization in OrganizationData.GenerateSampleOrganizations()) { if (organization.Id == TestConstants.OrganizationId3) { _billingManager.ApplyBillingPlan(organization, BillingManager.FreePlan, UserData.GenerateSampleUser()); } else { _billingManager.ApplyBillingPlan(organization, BillingManager.SmallPlan, UserData.GenerateSampleUser()); } _organizationRepository.Add(organization); } foreach (Project project in ProjectData.GenerateSampleProjects()) { var organization = _organizationRepository.GetById(project.OrganizationId); organization.ProjectCount += 1; _organizationRepository.Save(organization); _projectRepository.Add(project); } }
public Common.Data.JsonData Add(Organze model) { Common.Data.JsonData json = new Common.Data.JsonData() { Result = true }; if (string.IsNullOrEmpty(model.Name)) { json.Message = Lang.Tip_NameIsRequired; return(json); } if (string.IsNullOrEmpty(model.Code)) { model.Code = model.Name.TextConvertChar(); } model.CreateTime = DateTime.Now; try { json.Success = organzeDal.Add(model); } catch (Exception ex) { json.Message = ex.Message; } return(json); }
public void AddOrganization(OrganizationDTO model, string operatorId) { var organization = OrganizationFactory.CreateOrganization(model.FullName, model.ShortName, model.CertificateNo, model.Introduction, operatorId, model.Address, model.LogoImageId, model.Phone, model.CustomServicePhone); _organizationRepository.Add(organization); _dbUnitOfWork.Commit(); }
public ActionResult <Organization> PostOrganization(Organization organization) { _organizationRepository.Add(organization); _organizationRepository.Save(); return(CreatedAtAction("GetOrganization", new { id = organization.Id }, organization)); }
public ActionResult Add(Organization org) { if (Request.Files.Count <= 0) { ModelState.AddModelError("ImageValidation", "Image seçilmedir"); } if (Request.Files[0].ContentLength <= 0) { ModelState.AddModelError("ImageValidation", "Image seçilmedir"); } if (!ModelState.IsValid) { return(View(org)); } Images image = new Images(); image.imageUrl = Request.Files[0].FileName; _imageRepository.Add(image); var imagePath = ConfigurationManager.AppSettings["ImagePath"] + "/" + image.Id + "_" + image.imageUrl; Request.Files[0].SaveAs(imagePath); org.MainImageId = image.Id; org.Organizer = ((User)Session["User"]).Id; _organizationRepository.Add(org); return(RedirectToAction("Index")); }
public string CreateDefaultOrganizationAndProject(User user) { string organizationId = user.OrganizationIds.FirstOrDefault(); if (!String.IsNullOrEmpty(organizationId)) { var defaultProject = _projectRepository.GetByOrganizationId(user.OrganizationIds.First(), useCache: true).FirstOrDefault(); if (defaultProject != null) { return(defaultProject.Id); } } else { var organization = new Organization { Name = "Default Organization" }; BillingManager.ApplyBillingPlan(organization, Settings.Current.EnableBilling ? BillingManager.FreePlan : BillingManager.UnlimitedPlan, user); _organizationRepository.Add(organization); organizationId = organization.Id; } var project = new Project { Name = "Default Project", OrganizationId = organizationId }; project.NextSummaryEndOfDayTicks = DateTime.UtcNow.Date.AddDays(1).AddHours(1).Ticks; project.AddDefaultOwnerNotificationSettings(user.Id); project = _projectRepository.Add(project); _tokenRepository.Add(new Token { Id = StringExtensions.GetNewToken(), OrganizationId = organizationId, ProjectId = project.Id, CreatedUtc = DateTime.UtcNow, ModifiedUtc = DateTime.UtcNow, Type = TokenType.Access }); if (!user.OrganizationIds.Contains(organizationId)) { user.OrganizationIds.Add(organizationId); _userRepository.Save(user, true); } return(project.Id); }
public bool Add(Organization entity) { if (_repository.IsShortNameUnique(entity)) { return(_repository.Add(entity)); } throw new Exception("Short Name is not Unique!"); }
public void CreateOrganization(OrganizationEntity personEntity) { personEntity.IdOrganization = Guid.NewGuid(); personEntity.CreatedDate = DateTime.Now; personEntity.UpdatedDate = DateTime.Now; _organizationRepository.Add(personEntity); }
public async Task <bool> Create(Organization item) { //Execute domain validation for the create page operation Validate(item, Operation.Create); _repository.Add(item); //Save the changes to data layer return(await CompleteAsync()); }
public void CanCreateUpdateRemove() { _repository.RemoveAll(); Assert.Equal(0, _repository.Count()); var organization = new Organization(); Assert.Null(organization.Id); _repository.Add(organization); Assert.NotNull(organization.Id); organization = _repository.GetById(organization.Id); Assert.NotNull(organization); organization.Name = "New organization"; _repository.Save(organization); _repository.Remove(organization.Id); }
public IActionResult Create([FromBody] OrganizationViewModel item) { if (item == null) { return(BadRequest()); } string userName = User.Claims.GetClaim(JwtClaimTypes.Name); _repository.Add(item, userName); return(CreatedAtRoute("GetOrganization", new { id = item.Id }, item)); }
public void CanIncrementUsage() { var cache = IoC.GetInstance <ICacheClient>() as InMemoryCacheClient; Assert.NotNull(cache); cache.FlushAll(); var messages = new List <PlanOverage>(); var messagePublisher = IoC.GetInstance <IMessagePublisher>() as InMemoryMessageBus; Assert.NotNull(messagePublisher); messagePublisher.Subscribe <PlanOverage>(messages.Add); var o = _repository.Add(new Organization { Name = "Test", MaxEventsPerMonth = 750, PlanId = BillingManager.FreePlan.Id }); Assert.False(_repository.IncrementUsage(o.Id, false, 4)); Assert.Equal(0, messages.Count); Assert.Equal(4, cache.Get <long>(GetHourlyTotalCacheKey(o.Id))); Assert.Equal(4, cache.Get <long>(GetMonthlyTotalCacheKey(o.Id))); Assert.Equal(0, cache.Get <long>(GetHourlyBlockedCacheKey(o.Id))); Assert.Equal(0, cache.Get <long>(GetMonthlyBlockedCacheKey(o.Id))); Assert.True(_repository.IncrementUsage(o.Id, false, 3)); Assert.Equal(1, messages.Count); Assert.Equal(7, cache.Get <long>(GetHourlyTotalCacheKey(o.Id))); Assert.Equal(7, cache.Get <long>(GetMonthlyTotalCacheKey(o.Id))); Assert.Equal(1, cache.Get <long>(GetHourlyBlockedCacheKey(o.Id))); Assert.Equal(1, cache.Get <long>(GetMonthlyBlockedCacheKey(o.Id))); o = _repository.Add(new Organization { Name = "Test", MaxEventsPerMonth = 750, PlanId = BillingManager.FreePlan.Id }); Assert.True(_repository.IncrementUsage(o.Id, false, 751)); //Assert.Equal(2, messages.Count); Assert.Equal(751, cache.Get <long>(GetHourlyTotalCacheKey(o.Id))); Assert.Equal(751, cache.Get <long>(GetMonthlyTotalCacheKey(o.Id))); Assert.Equal(745, cache.Get <long>(GetHourlyBlockedCacheKey(o.Id))); Assert.Equal(745, cache.Get <long>(GetMonthlyBlockedCacheKey(o.Id))); }
protected override void CreateData() { Repository.Add(ProjectData.GenerateSampleProject()); _organizationRepository.Add(OrganizationData.GenerateSampleOrganizations()); var membershipProvider = new MembershipProvider(_userRepository.Collection); foreach (User user in UserData.GenerateSampleUsers()) { membershipProvider.CreateAccount(user); } }
public int AddOrganization(DLModel.Organization organization) { if (_organizationRepository.GetAll().Count() == 0) { organization.IsOrganizationAdmin = true; } else { organization.IsOrganizationAdmin = false; } return(_organizationRepository.Add(organization).OrganizationID); }
public void CanCreateUpdateRemove() { _repository.RemoveAll(); Assert.Equal(0, _repository.Count()); var organization = new Organization { Name = "Test Organization", PlanId = BillingManager.FreePlan.Id }; Assert.Null(organization.Id); _repository.Add(organization); Assert.NotNull(organization.Id); organization = _repository.GetById(organization.Id); Assert.NotNull(organization); organization.Name = "New organization"; _repository.Save(organization); _repository.Remove(organization.Id); }
public Organization Add( string title, string titleShort, Guid?parentOrganizationId, Guid organizationTypeId, string legalAddress, string postAddress, string phone, string fax, string email, string inn, string kpp, string ogrn, string okved, string okpo, string okato, string accountNumber, string bankTitle, string bik, string bankCorrespAccount) { var organization = _organizationFactory.Create( title, titleShort, parentOrganizationId, organizationTypeId); var organizationRequisites = _organizationRequisiteFactory.Create( organization.Id, legalAddress, postAddress, phone, fax, email, inn, kpp, ogrn, okved, okpo, okato, accountNumber, bankTitle, bik, bankCorrespAccount); _organizationRepository.Add(organization); _organizationRequisitesRepository.Add(organizationRequisites); return(organization); }
private void CreateData() { foreach (Organization organization in OrganizationData.GenerateSampleOrganizations()) { if (organization.Id == TestConstants.OrganizationId3) { _billingManager.ApplyBillingPlan(organization, BillingManager.FreePlan, UserData.GenerateSampleUser()); } else { _billingManager.ApplyBillingPlan(organization, BillingManager.SmallPlan, UserData.GenerateSampleUser()); } organization.StripeCustomerId = Guid.NewGuid().ToString("N"); organization.CardLast4 = "1234"; organization.SubscribeDate = DateTime.Now; if (organization.IsSuspended) { organization.SuspendedByUserId = TestConstants.UserId; organization.SuspensionCode = SuspensionCode.Billing; organization.SuspensionDate = DateTime.Now; } _organizationRepository.Add(organization); } foreach (Project project in ProjectData.GenerateSampleProjects()) { var organization = _organizationRepository.GetById(project.OrganizationId); _organizationRepository.Save(organization); _projectRepository.Add(project); } foreach (User user in UserData.GenerateSampleUsers()) { if (user.Id == TestConstants.UserId) { user.OrganizationIds.Add(TestConstants.OrganizationId2); user.OrganizationIds.Add(TestConstants.OrganizationId3); } if (!user.IsEmailAddressVerified) { user.VerifyEmailAddressToken = Guid.NewGuid().ToString(); user.VerifyEmailAddressTokenExpiration = DateTime.Now.AddDays(1); } _userRepository.Add(user); } }
public bool Add(Organization organization) { if (organization == null) { return(false); } if (organization.Code.Length != 3) { return(false); } return(_repository.Add(organization)); }
protected override void CreateData() { var membershipProvider = new MembershipProvider(_userRepository.Collection); foreach (User user in UserData.GenerateSampleUsers()) { membershipProvider.CreateAccount(user); } _projectRepository.Add(ProjectData.GenerateSampleProjects()); _organizationRepository.Add(OrganizationData.GenerateSampleOrganizations()); //_errorStackRepository.Add(ErrorStackData.GenerateErrorStack(id: TestConstants.ErrorStackId, organizationId: TestConstants.OrganizationId, projectId: TestConstants.ProjectId)); //_errorStackRepository.Add(ErrorStackData.GenerateErrorStack(id: TestConstants.ErrorStackId2, organizationId: TestConstants.OrganizationId, projectId: TestConstants.ProjectIdWithNoRoles)); }
public void CreateSampleOrganizationAndProject(string userId) { if (_tokenRepository.GetById(SAMPLE_API_KEY) != null) { return; } User user = _userRepository.GetById(userId, true); var organization = new Organization { Id = "537650f3b77efe23a47914f3", Name = "Acme" }; _billingManager.ApplyBillingPlan(organization, BillingManager.UnlimitedPlan, user); organization = _organizationRepository.Add(organization); var project = new Project { Id = "537650f3b77efe23a47914f4", Name = "Disintegrating Pistol", OrganizationId = organization.Id }; project.NextSummaryEndOfDayTicks = DateTime.UtcNow.Date.AddDays(1).AddHours(1).Ticks; project.Configuration.Settings.Add("IncludeConditionalData", "true"); project.AddDefaultOwnerNotificationSettings(userId); project = _projectRepository.Add(project); _tokenRepository.Add(new Token { Id = SAMPLE_API_KEY, OrganizationId = organization.Id, ProjectId = project.Id, ExpiresUtc = DateTime.UtcNow.AddYears(100), CreatedUtc = DateTime.UtcNow, ModifiedUtc = DateTime.UtcNow, Type = TokenType.Access }); _tokenRepository.Add(new Token { Id = SAMPLE_USER_API_KEY, OrganizationId = organization.Id, UserId = user.Id, ExpiresUtc = DateTime.UtcNow.AddYears(100), CreatedUtc = DateTime.UtcNow, ModifiedUtc = DateTime.UtcNow, Type = TokenType.Access }); user.OrganizationIds.Add(organization.Id); _userRepository.Save(user); }
protected void CreateData(int eventCount = 100) { var org = OrganizationData.GenerateSampleOrganization(); _organizationRepository.Add(org); var projects = ProjectData.GenerateSampleProjects(); _projectRepository.Add(projects); var events = EventData.GenerateEvents(eventCount, projectIds: projects.Select(p => p.Id).ToArray(), startDate: DateTime.Now.SubtractDays(60), endDate: DateTime.Now); foreach (var ev in events) { _eventPipeline.Run(ev); } }
protected void CreateData(int eventCount = 100, bool multipleProjects = true) { var orgs = OrganizationData.GenerateSampleOrganizations(); _organizationRepository.Add(orgs); var projects = ProjectData.GenerateSampleProjects(); _projectRepository.Add(projects); var events = EventData.GenerateEvents(eventCount, projectIds: multipleProjects ? projects.Select(p => p.Id).ToArray() : new[] { TestConstants.ProjectId }, startDate: DateTimeOffset.Now.SubtractDays(60), endDate: DateTimeOffset.Now); foreach (var eventGroup in events.GroupBy(ev => ev.ProjectId)) { _eventPipeline.Run(eventGroup); } }
public PublisherExtendedDto CreatePublisher(PublisherViewModel publisher) { var newPublisher = new organization_master { address1 = publisher.Address, countrycode = 354, createdby = "User", updatedby = "User", createdon = DateTime.Now, updatedon = DateTime.Now, isactive = true, name = publisher.Name, uniqueidentifier = publisher.SSN, zipcode = publisher.ZipCode, telephone = publisher.PhoneNumber, maincontact = publisher.MainContactName, maincontactemail = publisher.MainContactEmail, maincontacttel = publisher.MainContactPhoneNumber, website = publisher.Website, visibletopublic = true, organizationtype = 1 }; _organizationRepository.Add(newPublisher); _unitOfWork.Commit(); var createdPublisher = _organizationRepository.GetAll().OrderByDescending(i => i.id).First(); //return _organizationRepository.GetPublisherById(createdPublisher.id); return(new PublisherExtendedDto { Address = createdPublisher.address1, City = publisher.City, Id = createdPublisher.id, MainContactName = createdPublisher.maincontact, MainContactEmail = createdPublisher.maincontactemail, MainContactPhoneNumber = createdPublisher.maincontacttel, Name = createdPublisher.name, OrganizationType = "Almenn útgáfa", Website = createdPublisher.website, SSN = createdPublisher.uniqueidentifier, ZipCode = createdPublisher.zipcode }); }
/// <summary> /// Handler which processes the command when the eGov admin executes /// Register Organization command /// </summary> /// <param name="request"> carries the name of the organization as a parameter</param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <int> Handle(RegisterOrganizationCommand request, CancellationToken cancellationToken) { var code = _organizationRepository.GetNewCode(); var newOrganization = Domain.Organization.Organization.Register(request.Name, request.ShortName, code); _organizationRepository.Add(newOrganization); try { return(_organizationRepository .UnitOfWork .SaveChanges(request.RegisteredBy)); } catch (Exception ex) { throw ex; } }
public Organization AddNewOrganization(Organization value) { var organization = organizationRepository.Add(value); if (organization != null) { OrganizationUnit orgUnit = new OrganizationUnit() { OrganizationId = organization.Id, Name = "Common", IsVisibleToAllOrganizationMembers = true, CanDelete = false }; organizationUnitRepository.ForceIgnoreSecurity(); organizationUnitRepository.Add(orgUnit); } return(organization); }
// TODO: переделать на запросы, которые будут принимать пути для выполнения Include /// <summary> /// Выполнить команду Добавить или Обновить данные по организации сотрудника /// </summary> /// <param name="employeeId">Идентификатор иностранца</param> /// <param name="organizationDto">Данные по организации для создания организации</param> /// <returns>Идентификатор контакта</returns> public async Task <Guid> AddOrUpdateOrganizationAsync(Guid alienId, OrganizationDto organizationDto) { // TODO: проверить идентификатор, что не Guid.Empty var alien = await _alienRepository.GetAsync(alienId); if (alien.OrganizationId.HasValue) { await _organizationRepository.UpdateAsync(alien.OrganizationId.Value, organizationDto); } else { // TODO: переделать государственную регистрацию так, чтобы для сотрудников из одного места работы была одна гос. регистрация организации var organization = _organizationRepository.Add(organizationDto); alien.SetOrganization(organization); } return(alien.Organization !.Id); }
public Organization AddNewOrganization(Organization value) { value.MaxStorageInBytes = long.Parse(_config["Organization:MaxStorageInBytes"]); var organization = _organizationRepository.Add(value); if (organization != null) { OrganizationUnit orgUnit = new OrganizationUnit() { OrganizationId = organization.Id, Name = "Common", IsVisibleToAllOrganizationMembers = true, CanDelete = false }; _organizationUnitRepository.ForceIgnoreSecurity(); _organizationUnitRepository.Add(orgUnit); } return(organization); }
// TODO: переделать на запросы, которые будут принимать пути для выполнения Include /// <summary> /// Выполнить команду Добавить или Обновить данные по организации сотрудника /// </summary> /// <param name="employeeId">Идентификатор сотрудника</param> /// <param name="organizationDto">Данные по организации для создания организации</param> /// <returns>Идентификатор контакта</returns> public async Task <Guid> AddOrUpdateOrganizationAsync(Guid employeeId, OrganizationDto organizationDto) { // TODO: проверить идентификатор, что не Guid.Empty var employee = await _employeeRepository.GetAsync(employeeId); if (employee.OrganizationId.HasValue) { await _organizationRepository.UpdateAsync(employee.OrganizationId.Value, organizationDto); } else { // TODO: переделать государственную регистрацию так, чтобы для сотрудников из одного места работы была одна гос. регистрация организации var organization = _organizationRepository.Add(organizationDto); employee.SetOrganization(organization); } await _domainContext.SaveChangesAsync(); return(employee.Organization !.Id); }