public async Task <ResponseModel> DeleteAsync(int id)
        {
            var exisitingApplicant = await applicantRepository.FindByIdAsync(id);

            if (exisitingApplicant == null)
            {
                return new ResponseModel {
                           Success = false, Message = "Selected applicant is not exist", Data = null
                }
            }
            ;
            try
            {
                applicantRepository.Remove(exisitingApplicant);

                await unitOfWork.CompleteAsync();

                return(new ResponseModel {
                    Success = true, StatusCode = 200, Message = "Successfully removed selected applicant"
                });
            }
            catch (Exception ex)
            {
                // Do some logging stuff
                return(new ResponseModel {
                    Success = false, Message = $"An error occurred when deleting the applicant: {ex.Message}", StatusCode = 400
                });
            }
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Applicant applicant = _repository.Find(id);

            _repository.Remove(applicant);
            _repository.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public void Delete(int ID)
        {
            var applicant = repo.Get(ID);

            if (applicant == null)
            {
                throw new ApplicantMissingExcpetion(ID);
            }

            repo.Remove(applicant);
        }