コード例 #1
0
        public static Employer Create(string name, string city, string country, string username,
                                      string password, string email, string phone, long tenantId, EntityContext context)
        {
            username = username.Trim();
            if (string.IsNullOrEmpty(username))
            {
                throw new Exception("The username cannot be empty");
            }

            if (Account.Exists(username, tenantId))
            {
                throw new Exception("The username already exists.");
            }

            var account = new Account();

            account.Username      = username;
            account.Password      = AgileFx.Security.CryptoUtil.HashPassword(password);
            account.Status        = ACCOUNT_STATUS.ACTIVE;
            account.LastLoginDate = DateTime.Now;
            account.DateAdded     = DateTime.Now;
            account.Type          = ACCOUNT_TYPE.EMPLOYER;
            account.Email         = email;
            account.Phone         = phone;
            account.TenantId      = tenantId;

            var employer = new Employer();

            employer.Account    = account;
            employer.Name       = name;
            employer.City       = city;
            employer.Country    = country;
            employer.IsVerified = false;
            employer.TenantId   = tenantId;

            context.AddObject(employer);

            try
            {
                NotificationUtil.SendAdminEmail(string.Format("Employer Signup - Username {0}", username), "");
            }
            catch { }

            return(employer);
        }
コード例 #2
0
        public static Company Create(string companyName, string website, string city, string country, string username, string password,
                                     int?minimumRate, string currency, string email, string phone, string type, long tenantId, Entities context)
        {
            username = username.Trim();
            if (string.IsNullOrEmpty(username))
            {
                throw new Exception("The username cannot be empty");
            }

            if (Account.Exists(username, tenantId))
            {
                throw new Exception("The username already exists.");
            }

            var account = new Account();

            account.Username      = username;
            account.Password      = AgileFx.Security.CryptoUtil.HashPassword(password);
            account.Status        = ACCOUNT_STATUS.ACTIVE;
            account.LastLoginDate = DateTime.Now;
            account.DateAdded     = DateTime.Now;
            account.Type          = ACCOUNT_TYPE.COMPANY;
            account.Email         = email;
            account.Phone         = phone;
            account.TenantId      = tenantId;

            var company = new Company();

            company.Account     = account;
            company.Name        = companyName;
            company.Website     = website;
            company.City        = city;
            company.Country     = country;
            company.MinimumRate = minimumRate;
            company.Currency    = currency;
            company.Logo        = DEFAULT_IMAGES.COMPANY_LOGO;
            company.Type        = type;
            company.Description = "";
            company.Style       = PORTFOLIO_STYLE.SIMPLE;
            company.TenantId    = tenantId;

            if (type == COMPANY_TYPE.INDIVIDUAL)
            {
                company.Logo = DEFAULT_IMAGES.PROFILE_PICTURE;
            }

            foreach (var tag in context.Tag.Where(t => t.Name == "Web Design" || t.Name == ""))
            {
                company.Tags.Add(tag);
            }

            //Add a few portfolio entries
            company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE,
                                                 "Sample 1",
                                                 "",
                                                 DEFAULT_IMAGES.PAGE_PLACEHOLDER);

            company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE,
                                                 "Sample 2",
                                                 "",
                                                 DEFAULT_IMAGES.PAGE_PLACEHOLDER2);

            company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE,
                                                 "Sample 3",
                                                 "",
                                                 DEFAULT_IMAGES.PAGE_PLACEHOLDER3);

            //var projects = context.Project.Where(p => p.Employer.Account.Username == "bouncethru");
            //create an active bid for one of the sample projects.
            //var activeProject = projects.Where(p => p.ClosingDate >= DateTime.Now).First();
            //company.PlaceBid(activeProject.Id, 200, TIMEFRAME.MONTHS_2, 10000, 50000, "I am bidding on this sample project.");

            context.AddObject(company);

            try {
                NotificationUtil.SendAdminEmail(string.Format("Company Signup - Username {0}", username), "");
            }
            catch { }

            return(company);
        }