예제 #1
0
 public HttpResponseMessage Delete(long Id)
 {
     try
     {
         if (Id > 0)
         {
             CandidateRepository rep      = new CandidateRepository();
             Validate            repValid = rep.ValidateDelete(Id);
             if (repValid.IsValid)
             {
                 rep.Delete(Id);
                 return(Request.CreateResponse(HttpStatusCode.OK, "Operação efetuada com sucesso!"));
             }
             else
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, repValid.Message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Id inválido!"));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
     }
 }
예제 #2
0
 protected void OnMyAjaxManager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
 {
     CandidateAjaxManager.AjaxSettings.AddAjaxSetting(CandidateAjaxManager, RadCandidateGrid);
     if (e.Argument.IndexOf("DeletedSelectedCandidate") > -1)
     {
         if (RadCandidateGrid.SelectedItems.Count == 1)
         {
             CandidateRepository candRepo = new CandidateRepository();
             candRepo.Delete(new Candidate(GetSelectedCandidateID()));
             RadCandidateGrid.Rebind();
         }
     }
     else if (e.Argument.IndexOf("OpenSelectedCandidate") > -1)
     {
         if (RadCandidateGrid.SelectedItems.Count == 1)
         {
             int candidateID = GetSelectedCandidateID();
             if (candidateID > -1)
                 Response.Redirect("~/CandidateProfile.aspx?CandidateID=" + candidateID + "&mode=edit&backurl=visible", true);
         }
     }
     else if (e.Argument.IndexOf("ViewCandidateActions") > -1)
     {
         if (RadCandidateGrid.SelectedItems.Count == 1)
         {
             int candidateID = GetSelectedCandidateID();
             if (candidateID > -1)
                 Response.Redirect(string.Format("~/CandidateProfile.aspx?CandidateID={0}&tab=action&mode=edit&backurl=visible", candidateID, true));
         }
     }
 }
예제 #3
0
 public void Delete(int candidateId)
 {
     _candidateRepository.Delete(candidateId);
     if (_candidateList != null)
     {
         _candidateList.Remove(_candidateList.Where(c => c.Id == candidateId).FirstOrDefault());
     }
 }
예제 #4
0
        public ActionResult Delete(int id)
        {
            CandidateRepository cr = new CandidateRepository();

            try
            {
                cr.Delete(id);
                cr.Save();
                return(Json(new { success = true }));
            }
            catch (Exception e)
            {
                return(Json(new { success = false, message = e.Message }));
            }
        }
예제 #5
0
        public ActionResult <Candidate> DeleteCandidate(long id)
        {
            try
            {
                if (id == 0)
                {
                    return(BadRequest("Candidato não localizado"));
                }

                _repositoryCandidate.Delete(x => x.Id == id);
                _repositoryCandidate.Save();
                return(Ok());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
 internal int DeleteCandidate(int id)
 {
     return(candidateRepository.Delete(id));
 }