Example #1
0
        public ActionResult Put(int id, Applicant newApplicant)
        {
            ApplicantValidator validator = new ApplicantValidator();
            var validateResult           = validator.Validate(newApplicant);

            if (validateResult.IsValid)
            {
                newApplicant.ID = id;
                dbContext.Attach(newApplicant);
                dbContext.Entry(newApplicant).State = EntityState.Modified;
                dbContext.SaveChanges();
                return(Ok());
            }
            else
            {
                string allMessages = validateResult.ToString("~");
                return(BadRequest(new { Message = allMessages }));
            }
        }