Пример #1
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            if (User.Identity.IsAuthenticated && this.LoggedInAccount != null && this.LoggedInAccount.Type == ACCOUNT_TYPE.COMPANY)
            {
                this.Company = DbContext.Company.Where(c => c.Account == LoggedInAccount && c.TenantId == Tenant.Id)
                    .LoadRelated(c => c.Portfolio, c => c.Account, c => c.Consultants, c => c.Tags)
                    .Single();
            }
        }
Пример #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;
        }