public bool Delete(int id) { // Check whether lead exists or not ? var crmLead = _crmLeadRepository.Get(id); if (crmLead != null) { // Delete all Lead Activities var activities = _crmLeadActivityRepository.GetAllBy(m => m.CRMLeadId == id).ToList(); foreach (var activity in activities) { _crmLeadActivityRepository.Delete(activity); } // Delete all Lead Technology Maps var technologies = _crmLeadTechnologyMapRepository.GetAllBy(m => m.LeadId == id).ToList(); foreach (var technology in technologies) { _crmLeadTechnologyMapRepository.Delete(technology); } _unitOfWork.Commit(); _crmLeadRepository.Delete(id); _unitOfWork.Commit(); return(true); } return(false); }
public JsonResult AddNote(CRMActivityViewModel vm) { var selectedLead = _crmLeadRepository.Get(vm.CRMLeadId); if (selectedLead != null) { // Add it as an Activity var newActivity = new CRMLeadActivity { Title = vm.Title, Comment = vm.Comment, CRMLeadId = selectedLead.Id, CreatedByUserId = WebUser.Id }; _crmLeadActivityRepository.Create(newActivity); _unitOfWork.Commit(); return(Json(true)); } return(Json(false)); }
public ActionResult Get(int id) { var apiResult = TryExecute(() => _crmLeadRepository.Get(id), "Lead fetched sucessfully"); return(Json(apiResult, JsonRequestBehavior.AllowGet)); }