示例#1
0
 public ActionResult Edit([Bind(Include = "ApplicantId,ForeName,SurName,DOB,Title,AddressId,SalutationId,CVId,CreatedById,ModifiedById,DateCreated,DateModified")] Applicant applicant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(applicant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AddressId    = new SelectList(db.Addresses, "AddressId", "Street", applicant.AddressId);
     ViewBag.CreatedById  = new SelectList(db.AspNetUsers, "Id", "Email", applicant.CreatedById);
     ViewBag.CVId         = new SelectList(db.CVs, "CVId", "CreatedById", applicant.CVId);
     ViewBag.ModifiedById = new SelectList(db.AspNetUsers, "Id", "Email", applicant.ModifiedById);
     ViewBag.SalutationId = new SelectList(db.Salutations, "SalutationId", "ShortName", applicant.SalutationId);
     return(View(applicant));
 }
示例#2
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");
            }
        }
 public ActionResult Create([Bind(Include = "LanguageName,LanguageCompetenceLevelId")] LanguageCompetence languageCompetence)
 {
     if (ModelState.IsValid)
     {
         languageCompetence.CreatedById  = User.Identity.GetUserId();
         languageCompetence.ModifiedById = languageCompetence.CreatedById;
         languageCompetence.DateCreated  = DateTime.Now;
         languageCompetence.DateModified = languageCompetence.DateCreated;
         try
         {
             db.LanguageCompetences.Add(languageCompetence);
             db.SaveChanges();
         }
         catch (DbUpdateException ex) {
             var errorHelper = new ControllerHelpers();
             return(errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "LanguageCompetences", "Create"));
         }
         return(RedirectToAction("Index"));
     }
     ViewBag.LanguageCompetencesLevels = db.LanguageCompetenceLevels.ToList();
     return(View(languageCompetence));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "SkillName,SkillLevelId")] Skill skill)
        {
            if (ModelState.IsValid)
            {
                skill.CreatedById  = User.Identity.GetUserId();
                skill.ModifiedById = skill.CreatedById;
                skill.DateCreated  = DateTime.Now;
                skill.DateModified = skill.DateCreated;
                try
                {
                    db.Skills.Add(skill);
                    db.SaveChanges();
                }
                catch (DbUpdateException ex) {
                    var errorHelper = new ControllerHelpers();
                    return(errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "Skills", "Create"));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.SkillLevels = db.SkillLevels.ToList();
            return(View(skill));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "MonthStart,MonthEnd,YearStart,YearEnd,CompanyName,PositionHeld,Notes")] WorkExperience workExperience)
        {
            if (ModelState.IsValid)
            {
                workExperience.CreatedById  = User.Identity.GetUserId();
                workExperience.ModifiedById = workExperience.CreatedById;
                workExperience.DateCreated  = DateTime.Now;
                workExperience.DateModified = workExperience.DateCreated;
                try
                {
                    db.WorkExperiences.Add(workExperience);
                    db.SaveChanges();
                }
                catch (DbUpdateException ex) {
                    var errorHelper = new ControllerHelpers();
                    return(errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "WorkExperiences", "Create"));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.Month = UserHelpers.GetMonths();
            ViewBag.Year  = UserHelpers.GetYears();
            return(View(workExperience));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "MonthStart,MonthEnd,YearStart,YearEnd,InstitutionName,Notes")] Education education)
        {
            if (ModelState.IsValid)
            {
                education.CreatedById  = User.Identity.GetUserId();
                education.ModifiedById = education.CreatedById;
                education.DateCreated  = DateTime.Now;
                education.DateModified = education.DateCreated;
                try
                {
                    db.Educations.Add(education);
                    db.SaveChanges();
                }
                catch (DbUpdateException ex) {
                    var errorHelper = new ControllerHelpers();
                    return(errorHelper.CreateErrorPage(ex.InnerException.InnerException.Message, "Educations", "Create"));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.Month = UserHelpers.GetMonths();
            ViewBag.Year  = UserHelpers.GetYears();
            return(View(education));
        }
示例#7
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");
            }
        }