Esempio n. 1
0
        public Organization AddNewOrganization(CreateOrganization organizationBasic, string UserName)
        {
            int CurrenUser = 0;

            using (var db = new UserDAL())
            {
                CurrenUser = db.GetUserByUserNameOrEmail(UserName).UserID;
            }
            var newOrg = CreatEmptyOrganization();

            newOrg.OrganizationId    = CurrenUser;
            newOrg.OrganizationName  = organizationBasic.OrganizationName;
            newOrg.EOrganizationName = ConvertToUnSign.Convert(organizationBasic.OrganizationName);
            newOrg.Introduction      = organizationBasic.Introduction;
            newOrg.LogoUrl           = organizationBasic.LogoUrl;
            newOrg.Phone             = organizationBasic.Phone;
            newOrg.Email             = organizationBasic.Email;
            newOrg.Address           = organizationBasic.Address;
            newOrg.IsVerify          = false;
            newOrg.IsActive          = true;
            newOrg.Point             = 0;
            newOrg.CreatedDate       = DateTime.Now;

            using (var db = new Ws_DataContext())
            {
                db.Organizations.Add(newOrg);
                db.SaveChanges();
                return(GetOrganizationById(newOrg.OrganizationId));
            }
        }
Esempio n. 2
0
        public Organization EditOrganization(CreateOrganization organizationBasic, string UserName)
        {
            try
            {
                int CurrenUser = 0;
                using (var db = new UserDAL())
                {
                    CurrenUser = db.GetUserByUserNameOrEmail(UserName).UserID;
                }
                using (var db = new Ws_DataContext())
                {
                    var currentOrg = db.Organizations.Find(CurrenUser);

                    currentOrg.OrganizationName = organizationBasic.OrganizationName;
                    currentOrg.OrganizationName = organizationBasic.OrganizationName;
                    currentOrg.Introduction     = organizationBasic.Introduction;
                    if (organizationBasic.LogoUrl != "" && organizationBasic.LogoUrl != null)
                    {
                        currentOrg.LogoUrl = organizationBasic.LogoUrl;
                    }
                    currentOrg.Phone   = organizationBasic.Phone;
                    currentOrg.Address = organizationBasic.Address;

                    db.SaveChanges();

                    return(GetOrganizationById(currentOrg.OrganizationId));
                }
            }
            catch (Exception)
            {
                return(null);
                //throw;
            }
        }
Esempio n. 3
0
        public void CreateOrganization_Action_Fails()
        {
            // Arrange
            var organizationDto = TestHelper.OrganizationDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.OrganizationService.CreateOrganization(organizationDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new CreateOrganization <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(organizationDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
        public async Task <ActionResult <Guid> > Register(RegisterOrganizationDto registerOrganizationDto)
        {
            var logo     = registerOrganizationDto.Logo;
            var images   = registerOrganizationDto.Images;
            var contacts = registerOrganizationDto.Contacts;

            return(Created(string.Empty, await _organizationsService.RegisterOrganizationAsync(
                               await Organization.NewAsync(CreateOrganization.New(
                                                               OrganizationType.GetById(registerOrganizationDto.OrganizationTypeId),
                                                               new CreateOrUpdateContacts(
                                                                   contacts.ActualAddress,
                                                                   contacts.ActualGeoPosition,
                                                                   contacts.PhoneNumber,
                                                                   contacts.Email,
                                                                   contacts.Site,
                                                                   contacts.Telegram,
                                                                   contacts.Instagram,
                                                                   contacts.Vk),
                                                               registerOrganizationDto.LegalName,
                                                               registerOrganizationDto.LegalAddress,
                                                               registerOrganizationDto.ActualName,
                                                               registerOrganizationDto.TIN,
                                                               logo == null ? null : CreateOrganizationLogo.New(logo),
                                                               images == null ? Enumerable.Empty <CreateImage>() : images.Select(CreateImage.New))))));
        }
Esempio n. 5
0
        private void initObjectModels()
        {
            // initializing footer objects
            terms         = new Terms(browser);
            privacy       = new Privacy(browser);
            security      = new Security(browser);
            status        = new Status(browser);
            help          = new Help(browser);
            footerLogo    = new pageObjectModels.footer.Logo(browser);
            contactGitHub = new ContactGitHub(browser);
            api           = new API(browser);
            training      = new Training(browser);
            shop          = new Shop(browser);
            footerBlog    = new pageObjectModels.footer.Blog(browser);
            about         = new About(browser);

            // initializing explore objects
            integrations = new Integrations(browser);
            showcases    = new Showcases(browser);
            trending     = new Trending(browser);

            // initializing header objects
            headerLogo = new pageObjectModels.header.Logo(browser);
            personal   = new Personal(browser);
            openSource = new OpenSource(browser);
            business   = new Business(browser);
            explore    = new Explore(browser);
            pricing    = new Pricing(browser);
            headerBlog = new pageObjectModels.header.Blog(browser);
            support    = new Support(browser);
            searchBar  = new pageObjectModels.header.SearchBar(browser);
            signIn     = new SignIn(browser);
            signUp     = new SignUp(browser);

            // initializing main objects
            signUpUsername  = new SignUpUsername(browser);
            signUpEmail     = new SignUpEmail(browser);
            signUpPassword  = new SignUpPassword(browser);
            signUpSubmit    = new SignUpSubmit(browser);
            signUpForGitHub = new SignUpForGitHubButton(browser);

            // initializing pricing objects
            joinGitHubForFree    = new JoinGitHubForFree(browser);
            upgradeAccount       = new UpgradeAccount(browser);
            createOrganization   = new CreateOrganization(browser);
            startEnterpriseTrial = new StartEnterpriseTrial(browser);

            // initializing blog objects
            featured      = new Featured(browser);
            allPosts      = new AllPosts(browser);
            newFeatures   = new NewFeatures(browser);
            engineering   = new Engineering(browser);
            enterprise    = new Enterprise(browser);
            conferences   = new Conferences(browser);
            meetups       = new Meetups(browser);
            newHires      = new NewHires(browser);
            watercooler   = new Watercooler(browser);
            blogSearchBar = new pageObjectModels.blog.SearchBar(browser);
        }
Esempio n. 6
0
 void CreateButton_Clicked()
 {
     CreateOrganization.Run(
         mRestApi,
         new CreateOrganization.Data(
             mOrganizationNameTextField.text,
             mDatacenter.text,
             mEncryptData.value),
         mProgressControls,
         this);
 }
        public async Task <ActionResult <CreateOrganizationResult> > Post([FromBody] CreateOrganization createOrganization, [FromQuery] bool redirect = true)
        {
            CreateOrganizationResult createOrganizationResult = await _mediator.Send(createOrganization);

            if (redirect)
            {
                TempData.Put(createOrganizationResult);
                return(RedirectToAction(nameof(Index)));
            }

            return(createOrganizationResult);
        }
Esempio n. 8
0
        public void TestAddOrganizations()
        {
            var orgStructureTypeId = Guid.NewGuid().ToString();
            var orgStructureType   = new CreateOrganizationStructureType();

            orgStructureType.Id = orgStructureTypeId;
            organizationStructureTypeApplicationService.When(orgStructureType);

            var organization1 = new CreateOrganization();

            organization1.OrganizationId = Guid.NewGuid().ToString();
            organization1.Name           = "Org_test_1" + organization1.OrganizationId;
            organizationApplicationService.When(organization1);

            var organization2 = new CreateOrganization();

            organization2.OrganizationId = Guid.NewGuid().ToString();
            organization2.Name           = "Org_test_2" + organization2.OrganizationId;
            organizationApplicationService.When(organization2);

            var orgStructure_0_1    = new CreateOrganizationStructure();
            var orgStructure_0_1_Id = new OrganizationStructureId(orgStructureTypeId, "", organization1.OrganizationId);

            orgStructure_0_1.Id = orgStructure_0_1_Id;
            organizationStructureApplicationService.When(orgStructure_0_1);

            var orgStructure_1_2    = new CreateOrganizationStructure();
            var orgStructure_1_2_Id = new OrganizationStructureId(orgStructureTypeId, organization1.OrganizationId, organization2.OrganizationId);

            orgStructure_1_2.Id = orgStructure_1_2_Id;
            organizationStructureApplicationService.When(orgStructure_1_2);

            var roots = organizationTreeRepository.GetRoots((IEnumerable <KeyValuePair <string, object> >)null, null).ToList();

            Assert.GreaterOrEqual(roots.Count, 1);
            Console.WriteLine(roots[0].Content.OrganizationId);
            if (roots != null && roots.Count > 0)
            {
                Assert.GreaterOrEqual(roots[0].Children.Count(), 1);
                foreach (var c in roots[0].Children)
                {
                    Console.WriteLine(c.Content.OrganizationId);
                }
            }
        }
Esempio n. 9
0
        public static async Task <Organization> NewAsync(CreateOrganization createOrganization)
        {
            var images = new List <OrganizationImage>(createOrganization.Images.Count());

            foreach (var image in createOrganization.Images)
            {
                images.Add(await OrganizationImage.NewAsync(image));
            }
            return(new Organization(
                       createOrganization.Guid,
                       createOrganization.Type,
                       Contacts.New(createOrganization.Contacts),
                       createOrganization.LegalName,
                       createOrganization.LegalAddress,
                       createOrganization.ActualName,
                       createOrganization.TIN,
                       createOrganization.Logo == null ? null : await OrganizationLogo.NewAsync(createOrganization.Logo),
                       images));
        }
Esempio n. 10
0
        public ActionResult CreateOrganization(CreateOrganization organization, HttpPostedFileBase LogoImage)
        {
            //Models.Organization newOrganization;
            try
            {
                string logoName = WsConstant.randomString() + Path.GetExtension(LogoImage.FileName).ToLower();
                string path     = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Upload"), logoName);
                LogoImage.SaveAs(path);
                organization.LogoUrl = "/Content/Upload/" + logoName;

                using (var db = new OrganizationDAL())
                {
                    db.AddNewOrganization(organization, User.Identity.Name);
                }
            }
            catch (Exception)
            {
                return(Redirect("/#/Error"));
            }

            return(Redirect("/#/Home"));
        }
Esempio n. 11
0
        public object Post(CreateOrganization request)
        {
            var slugExists = Db.Exists <Organization>(x => x.Slug == request.Slug);

            if (slugExists)
            {
                throw new ArgumentException("Slug already exists", nameof(request.Slug));
            }

            var user = GetUser();

            var org       = request.ConvertTo <Organization>();
            var orgMember = new OrganizationMember
            {
                UserId   = user.GetUserId(),
                UserName = user.UserName,
                IsOwner  = true
            };

            org.Created   = org.Modified = orgMember.Created = DateTime.Now;
            org.CreatedBy = org.ModifiedBy = orgMember.CreatedBy = user.UserName;

            orgMember.OrganizationId = (int)Db.Insert(org, selectIdentity: true);

            Db.Insert(orgMember);

            SendSystemEmail(nameof(CreateOrganization),
                            $"New {request.Name} Organization was created by {user.UserName} at /{request.Slug}");

            ClearOrganizationCaches();

            return(new CreateOrganizationResponse
            {
                Id = orgMember.OrganizationId,
                Slug = request.Slug,
            });
        }
Esempio n. 12
0
        public ActionResult EditOrganization(CreateOrganization organization, HttpPostedFileBase LogoImage)
        {
            try
            {
                Organization organi = new Organization();
                if (LogoImage != null)
                {
                    string logoName = WsConstant.randomString() + Path.GetExtension(LogoImage.FileName).ToLower();
                    string path     = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Content/Upload"), logoName);
                    LogoImage.SaveAs(path);
                    organization.LogoUrl = "/Content/Upload/" + logoName;
                }

                using (var db = new OrganizationDAL())
                {
                    organi = db.EditOrganization(organization, User.Identity.Name);
                }
                return(Redirect("/#/OrganizationDetail/" + organi.OrganizationId));
            }
            catch (Exception)
            {
                return(Redirect("/#/Error"));
            }
        }
Esempio n. 13
0
        public bool APICreateOrganization(object[] lStrvalue)
        {
            string header = string.Empty;

            string     statusCode   = string.Empty;
            string     result       = string.Empty;
            clsGeneric oGeneric     = new clsGeneric();
            string     URI          = string.Empty;
            Hashtable  htblTestData = new Hashtable();

            htblTestData = oGeneric.GetTestData(lStrvalue);
            bool _Flag = false;


            CreateOrganization         oCreateOrganization         = new CreateOrganization();
            CreateOrganizationUserData oCreateOrganizationUserData = new CreateOrganizationUserData();

            try
            {
                oCreateOrganization.Name       = htblTestData["OrganizationName"].ToString().Trim();
                oCreateOrganization.FolderName = htblTestData["FolderName"].ToString().Trim();


                oCreateOrganizationUserData.F001 = htblTestData["UserFirstName"].ToString().Trim();
                oCreateOrganizationUserData.F002 = htblTestData["UserLastName"].ToString().Trim();
                oCreateOrganizationUserData.F003 = htblTestData["UserMiddleName"].ToString().Trim();
                oCreateOrganizationUserData.F008 = htblTestData["Address1"].ToString().Trim();
                oCreateOrganizationUserData.F009 = htblTestData["Address2"].ToString().Trim();
                oCreateOrganizationUserData.F010 = htblTestData["City"].ToString().Trim();
                oCreateOrganizationUserData.F011 = htblTestData["Country"].ToString().Trim();
                oCreateOrganizationUserData.F012 = htblTestData["State"].ToString().Trim();
                oCreateOrganizationUserData.F013 = htblTestData["Region"].ToString().Trim();
                oCreateOrganizationUserData.F014 = htblTestData["ZipCode"].ToString().Trim();
                oCreateOrganizationUserData.F015 = htblTestData["EmailID"].ToString().Trim();
                oCreateOrganizationUserData.F016 = htblTestData["Password"].ToString().Trim();
                oCreateOrganizationUserData.F017 = htblTestData["Phone"].ToString().Trim();
                oCreateOrganizationUserData.F018 = htblTestData["Fax"].ToString().Trim();
                oCreateOrganizationUserData.F023 = htblTestData["TimeZone"].ToString().Trim();

                oCreateOrganization.OrganizationAdmin = oCreateOrganizationUserData;


                oGeneric.GetApiResponseCodeData(out statusCode, out result, htblTestData["MethodType"].ToString().Trim(), clsAPI.apiURI + htblTestData["URI"].ToString().Trim(), oCreateOrganization, htblTestData["HeaderType"].ToString().Trim(), "", "");


                if (htblTestData["TestCaseType"].ToString().ToUpper() == "POSITIVE")
                {
                    if (result.ToUpper().Contains("!DOCTYPE"))
                    {
                        clsGlobalVariable.strExceptionReport = "Resource not found";
                        return(true);
                    }
                    if (statusCode.Contains("20"))
                    {
                        var oResult = JsonConvert.DeserializeObject <CreateOrganizationUserDataOutput>(result);
                        if (oResult.OrganizationName == htblTestData["OrganizationName"].ToString().Trim())
                        {
                            return(true);
                        }
                        else
                        {
                            clsGlobalVariable.strExceptionReport = "Organization Not Found";
                            return(false);
                        }
                    }
                }
                else if (htblTestData["TestCaseType"].ToString().ToUpper() == "NEGATIVE")
                {
                    if (result.ToUpper().Contains("!DOCTYPE"))
                    {
                        return(true);
                    }

                    if (statusCode.Contains("40") || statusCode.Contains("50"))
                    {
                        if (statusCode.Contains("404") || statusCode.Contains("500") || statusCode.Contains("405"))
                        {
                            return(true);
                        }
                        var oError = JsonConvert.DeserializeObject <List <SuperAdminCoursePushDownError> >(result);
                        SuperAdminCoursePushDownErrorCode oErrorCode = new SuperAdminCoursePushDownErrorCode();
                        foreach (string strErrorCode in oErrorCode.coursePushDownErrorCode)
                        {
                            for (int iError = 0; iError < oError.Count; iError++)
                            {
                                if (strErrorCode == oError[iError].ErrorCode)
                                {
                                    _Flag = true;
                                }
                            }
                        }

                        if (_Flag == true)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        clsGlobalVariable.strExceptionReport = "Resource or URI Wrong!";
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                clsException.ExceptionHandler(e, iWebdriver, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().Name);

                return(false);
            }
        }
Esempio n. 14
0
 public async Task HandleAsync(CreateOrganization command)
 => await CreateForAuthenticatedUserAsync(command);
Esempio n. 15
0
 public async Task HandleAsync(CreateOrganization command)
 => await ProcessAsync(command);