예제 #1
0
        public IHttpActionResult Post(ApplicantCreate application)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateApplicantServices();

            if (!service.CreateApplicant(application))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
예제 #2
0
        public bool CreateApplicant(ApplicantCreate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var applicant = ctx.Applicants.SingleOrDefault(e => e.OwnerId == _userId);
                if (applicant != null)
                {
                    return(false);
                }
                var entity = new Applicant()
                {
                    OwnerId            = _userId,
                    ApplicantFirstName = model.ApplicantFirstName,
                    ApplicantEmail     = model.ApplicantEmail,
                    ApplicantLastName  = model.ApplicantLastName,
                };

                ctx.Applicants.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }