Exemplo n.º 1
0
        public static MarketingCampaign CreateMarketingCampaign(string companyName, string website, string city, string country,
            string username, string email, string phone, HttpFileCollectionBase postedFiles, string description,
            HttpPostedFileBase logoFile, string referringURL, Action<EntityContext, Company> createPortfolios)
        {
            var context = new Entities();

            if (Account.Exists(username))
                throw new Exception("The username already exists.");

            var account = new Account();
            account.Username = username;
            account.Password = AgileFx.Security.CryptoUtil.HashPassword(Guid.NewGuid().ToString());
            account.Status = ACCOUNT_STATUS.ACTIVE;
            account.LastLoginDate = DateTime.Now;
            account.DateAdded = DateTime.Now;
            account.Type = ACCOUNT_TYPE.COMPANY;
            account.Email = email;

            var company = new Company();
            company.Account = account;
            company.Name = companyName;
            company.Website = website;
            company.City = city;
            company.Country = country;
            company.Phone = phone;

            if (logoFile.ContentLength > 0)
                company.SaveLogo(logoFile);

            company.Description = description;

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

            createPortfolios(context, company);

            context.AddObject(company);
            context.SaveChanges();

            var marketingCamp = new MarketingCampaign();
            marketingCamp.Account = account.Id;
            marketingCamp.DateCreated = DateTime.UtcNow;
            marketingCamp.DateModified = DateTime.UtcNow;
            marketingCamp.ReferringURL = referringURL;
            marketingCamp.Status = MARKETING_CAMPAIGN_STATUS.NEW;
            marketingCamp.Token = Guid.NewGuid();

            context.AddObject(marketingCamp);
            context.SaveChanges();

            return marketingCamp;
        }
Exemplo n.º 2
0
        public virtual void Create(TEntity entity)
        {
            Entities.AddObject(entity);
            Context.SaveChanges();

            if (this.EnableLog)
            {
                Library.Log.LogService.LogInformation("Create {0} with key={1}".FormatWith(typeof(TEntity).Name, entity.EntityKey.EntityKeyValues[0].Value));
            }
        }
Exemplo n.º 3
0
 public virtual void Create(IEnumerable <TEntity> entities)
 {
     foreach (TEntity entity in entities)
     {
         Entities.AddObject(entity);
     }
     Context.SaveChanges();
     if (this.EnableLog)
     {
         var entityKeys = string.Join(",", entities.Select(x => x.EntityKey.EntityKeyValues[0].Value));
         Library.Log.LogService.LogInformation("Create {0} with key={1}".FormatWith(typeof(TEntity).Name, entityKeys));
     }
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Insert Into Database
 /// </summary>
 /// <param name="entity"></param>
 public override void Add(Merk entity)
 {
     entity.CreatedBy  = Environment.UserName;
     entity.CreateDate = DateTime.Now;
     Entities.AddObject(entity);
 }
Exemplo n.º 6
0
        public static MarketingCampaign CreateMarketingCampaign(string companyName, string website, string city, string country,
                                                                string username, string email, string phone, HttpFileCollectionBase postedFiles, string description,
                                                                HttpPostedFileBase logoFile, string referringURL, Action <EntityContext, Company> createPortfolios)
        {
            var context = new Entities();

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

            var account = new Account();

            account.Username      = username;
            account.Password      = AgileFx.Security.CryptoUtil.HashPassword(Guid.NewGuid().ToString());
            account.Status        = ACCOUNT_STATUS.ACTIVE;
            account.LastLoginDate = DateTime.Now;
            account.DateAdded     = DateTime.Now;
            account.Type          = ACCOUNT_TYPE.COMPANY;
            account.Email         = email;

            var company = new Company();

            company.Account = account;
            company.Name    = companyName;
            company.Website = website;
            company.City    = city;
            company.Country = country;
            company.Phone   = phone;

            if (logoFile.ContentLength > 0)
            {
                company.SaveLogo(logoFile);
            }

            company.Description = description;

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

            createPortfolios(context, company);

            context.AddObject(company);
            context.SaveChanges();

            var marketingCamp = new MarketingCampaign();

            marketingCamp.Account      = account.Id;
            marketingCamp.DateCreated  = DateTime.UtcNow;
            marketingCamp.DateModified = DateTime.UtcNow;
            marketingCamp.ReferringURL = referringURL;
            marketingCamp.Status       = MARKETING_CAMPAIGN_STATUS.NEW;
            marketingCamp.Token        = Guid.NewGuid();

            context.AddObject(marketingCamp);
            context.SaveChanges();

            return(marketingCamp);
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
0
 private static void CreateControls()
 {
     context.AddObject(new Control {
         Name = "Default PageTitle", Type = "PageTitle", VirtualPath = "~/Views/Pages/Blog/PageTitleControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default BlogPost", Type = "BlogPost", VirtualPath = "~/Views/Pages/Blog/BlogPostControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default BlogPost List", Type = "BlogPostList", VirtualPath = "~/Views/Pages/Blog/BlogPostListControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default Archives", Type = "Archives", VirtualPath = "~/Views/Pages/Blog/ArchivesControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default Tags", Type = "Tags", VirtualPath = "~/Views/Pages/Blog/TagsControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default Comments", Type = "Comments", VirtualPath = "~/Views/Pages/Blog/CommentsControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default RecentPosts", Type = "RecentPosts", VirtualPath = "~/Views/Pages/Blog/RecentPostsControl.ascx"
     });
     context.AddObject(new Control {
         Name = "Default Meta", Type = "Meta", VirtualPath = "~/Views/Pages/Blog/MetaControl.ascx"
     });
     context.SaveChanges();
 }