Example #1
0
        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);
        }
Example #2
0
        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));
        }
Example #3
0
        public ActionResult Get(int id)
        {
            var apiResult = TryExecute(() => _crmLeadRepository.Get(id), "Lead fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }