Example #1
0
        public IActionResult Post([FromBody] Applicant a)
        {
            ApplicantValidator v      = new ApplicantValidator();
            ValidationResult   result = v.Validate(a);

            if (result.IsValid)
            {
                var qu   = _applicantContext.Applicants.Add(a);
                var user = _applicantContext.SaveChanges();
                return(Created("/" + a.ID, user));
            }
            else
            {
                return(BadRequest());
            }
        }
        // GET: Applicants
        public ActionResult Index()
        {
            List <Applicant> apps = db.Applicants.ToList();

            foreach (var a in apps)
            {
                //if (a.gradesEntered())
                //{
                a.calculateAll();
                a.name            = GetName(a.Id);
                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();
                //}
            }

            return(View(apps));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="applicant"></param>
        /// <returns></returns>
        public Task DeleteApplicant(T applicant)
        {
            Applicant applicantDB = applicant as Applicant;

            using (var context = new ApplicantContext(dbContextOptions))
            {
                context.Applicants.Remove(applicantDB);
                context.SaveChanges();
            }
            return(Task.CompletedTask);
        }
Example #4
0
        public bool DeleteApplicant(int id)
        {
            try
            {
                Applicant app = _context.Applicants.Where(a => a.ID == id).FirstOrDefault();
                if (app != null)
                {
                    _context.Applicants.Remove(app);
                    _context.SaveChanges();
                    _logger.LogInformation($"user with id:{id} deleted successfully");
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message + " " + ex.StackTrace);
                return(false);
            }
        }
 public bool Delete(Applicant Item)
 {
     db.Remove(Item);
     ctx.SaveChanges();
     return(true);
 }