예제 #1
0
        public IHttpActionResult Update(EmploymentSaveDto employment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            service.Update(employment);

            //var result = mapper.Map<EmploymentDto>(employment);
            return(Ok());
        }
예제 #2
0
        public ActionResult EmploymentInfo(Employments employments)
        {
            var tracker = (Guid)Session["Tracker"];

            if (ModelState.IsValid)
            {
                var applicant = _applicantService.GetApplicantsByTraker(tracker);

                var existingEmployment = applicant.Employment.FirstOrDefault(x => x.IsPrimary);
                if (existingEmployment != null)
                {
                    _employmentService.Update(existingEmployment);
                }
                else
                {
                    var newEmployment = Mapper.Map <EmploymentDto>(employments.PrimaryEmployer);
                    newEmployment.IsPrimary = true;
                    _employmentService.Create(newEmployment);
                }


                var existingPrevious = applicant.Employment.FirstOrDefault(x => x.IsPrimary == false);
                if (existingPrevious != null)
                {
                    var newEmployment = Mapper.Map(employments.PreviousEmployer, existingPrevious);
                    _employmentService.Update(existingPrevious);
                }
                else
                {
                    var newEmployment = Mapper.Map <EmploymentDto>(employments.PreviousEmployer);
                    newEmployment.IsPrimary = false;
                    _employmentService.Create(newEmployment);
                }

                return(RedirectToAction("VehicleInfo", "Vehicle"));
            }
            return(View());
        }