Example #1
0
        /// <summary>
        /// Creates a Company entity using an Application User as basis
        /// </summary>
        /// <param name="user">ApplicationUser</param>
        /// <param name="model">RegisterViewModel</param>
        public static void CreateCompanyFromIdentity(ApplicationUser user, RegisterViewModel model)
        {
            var company = new Company
            {
                CompanyName  = model.CompanyName,
                UserName     = user.UserName,
                ContactName  = model.ContactName,
                EmailAddress = user.Email,
                Telephone    = model.Telephone,
                Website      = model.Website,
                AspNetUserId = user.Id
            };

            var db = new ApplyEntities();

            try
            {
                db.Companies.Add(company);
                db.SaveChanges();
            }
            catch (DbUpdateException ex) {
                var errorHelper = new ControllerHelpers();
                errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "Account", "Register");
            }
        }
Example #2
0
        /// <summary>
        /// Creates a geek entity using an Application User as basis
        /// </summary>
        /// <param name="user">ApplicationUser</param>
        public static void CreateApplicantFromIdentity(ApplicationUser user)
        {
            var applicant = new Applicant
            {
                ApplicantId  = user.Id,
                ForeName     = user.Forename ?? "",
                SurName      = user.Surname ?? "",
                CreatedById  = user.Id,
                ModifiedById = user.Id,
                DateCreated  = DateTime.Now
            };

            applicant.DateModified = applicant.DateCreated;
            var db = new ApplyEntities();

            try {
                db.Applicants.Add(applicant);
                db.SaveChanges();
            }
            catch (DbUpdateException ex) {
                var errorHelper = new ControllerHelpers();
                errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "Account", "Register");
            }
        }