Example #1
0
        public MyContactListModel GetForAcceptance(FormDataCollection form)
        {
            var printId = ConvertHelper.ToInt32(form.Get("printId"));
            var pageCode = ConvertHelper.ToString(form.Get("pageCode"));
            var levelId = ConvertHelper.ToInt32(form.Get("levelId"));
            var page = ConvertHelper.ToInt32(form.Get("page"));
            var rows = ConvertHelper.ToInt32(form.Get("rows"));
            int totalRecords;
            var list = new MyContactListModel();
            var lstModel = new List<ContactModel>();
            var data = ContactRepository.GetForAcceptance(printId, pageCode, levelId, page, rows, out totalRecords) ?? new List<ContactInfo>();
            if (!data.IsNullOrEmpty())
            {
                var lstPhones = PhoneRepository.GetByContacts(data.Select(c => c.Id.ToString()).Aggregate((total, curent) => total + "," + curent));
                foreach (var info in data)
                {
                    var objModel = new ContactModel();
                    ObjectHelper.Transform(info, ref objModel);

                    var contactLevel = ContactLevelInfoRepository.GetInfo(info.Id);
                    ObjectHelper.Transform(contactLevel, ref objModel);

                    foreach (var phone in lstPhones.Where(c => c.ContactId == info.Id))
                    {
                        if (phone.IsPrimary == 1) objModel.Mobile = phone.PhoneNumber;
                        if (phone.IsPrimary != 1 && phone.PhoneType == PhoneType.HomePhone.ToString())
                            objModel.Tel = phone.PhoneNumber;
                        if (phone.IsPrimary != 1 && phone.PhoneType == ((int)PhoneType.MobilePhone).ToString())
                            objModel.Mobile2 = phone.PhoneNumber;
                    }

                    // StatusName
                    objModel.StatusName = ObjectExtensions.GetEnumDescription((StatusType)objModel.StatusId);

                    // StatusMap
                    if (objModel.StatusMapDistributorId != null)
                        objModel.StatusMapId = objModel.StatusMapDistributorId.Value;
                    lstModel.Add(objModel);
                }
            }

            list.UserData = totalRecords;
            list.Rows = lstModel;
            list.Page = page;
            list.Total = (totalRecords / rows) + 1;
            list.Records = rows;
            return list;
        }
Example #2
0
        public JsonResult GetForFilterTeam(int branchId, int collectorId, int channelId, int importId, int levelId, int sourceTypeId, int schoolId, int statusId, int page, int rows)
        {
            var list = new MyContactListModel();
            var lstModel = new List<ContactModel>();
            int totalRecords;
            var data = ContactRepository.GetForFilterTeam(branchId, collectorId, channelId, importId, levelId, sourceTypeId, schoolId, statusId, page, rows, out totalRecords);
            foreach (var info in data)
            {
                var objModel = ObjectHelper.Transform<ContactModel, ContactInfo>(info);
                objModel.StatusName = ObjectExtensions.GetEnumDescription((StatusType)info.StatusId);
                var contactLevel = ContactLevelInfoRepository.GetInfo(info.Id);
                if (contactLevel != null)
                {
                    objModel.Notes = contactLevel.EducationSchoolName;
                }
                var collector = CollectorRepository.GetInfo(info.CollectorId);
                var channel = ChannelRepository.GetInfo(info.ChannelId);
                var phones = PhoneRepository.GetByContact(info.Id);
                foreach (var phone in phones)
                {
                    if (phone.IsPrimary == 1)
                    {
                        objModel.Mobile = phone.PhoneNumber;
                    }
                    else if (phone.PhoneType == PhoneType.HomePhone.ToString())
                    {
                        objModel.Tel = phone.PhoneNumber;
                    }
                    else
                    {
                        objModel.Mobile2 = phone.PhoneNumber;
                    }

                }
                if (collector != null) objModel.CollectorName = collector.Name;
                if (channel != null) objModel.ChannelName = channel.Name;

                lstModel.Add(objModel);
            }
            list.UserData = totalRecords;
            list.Rows = lstModel;
            list.Page = page;
            list.Total = (totalRecords / rows) + 1;
            list.Records = rows;
            return new JsonResult { Data = list, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
        }
Example #3
0
        public MyContactListModel Get(string action, int branchId, int collectorId, int channelId, int importId, int levelId, int sourceTypeId, int schoolId, int statusId,string importDate, int page, int rows)
        {
            int totalRecords;
            var list = new MyContactListModel();
            var lstModel = new List<ContactModel>();
            var importFDate = importDate.ToDateTime("ddMMyyyy");
            var data = action == "duplicatemo"
                            ? ContactRepository.SearchDuplicateMo(collectorId, channelId, importId, levelId, sourceTypeId, branchId, importFDate, page, rows, out totalRecords)
                            : ContactRepository.Search(collectorId, channelId, importId, levelId, sourceTypeId, statusId, page, rows, out totalRecords);

            foreach (var info in data)
            {
                var objModel = ObjectHelper.Transform<ContactModel, ContactInfo>(info);
                var collector = CollectorRepository.GetInfo(info.CollectorId);
                var channel = ChannelRepository.GetInfo(info.ChannelId);
                var phones = PhoneRepository.GetByContact(info.Id);
                foreach (PhoneInfo phone in phones)
                {
                    if (phone.IsPrimary == 1)
                    {
                        objModel.Mobile = phone.PhoneNumber;
                    }
                    else if (phone.PhoneType == PhoneType.HomePhone.ToString())
                    {
                        objModel.Tel = phone.PhoneNumber;
                    }
                    else
                    {
                        objModel.Mobile2 = phone.PhoneNumber;
                    }

                }
                if (collector != null) objModel.CollectorName = collector.Name;
                if (channel != null) objModel.ChannelName = channel.Name;
                lstModel.Add(objModel);
            }
            list.UserData = totalRecords;
            list.Rows = lstModel;
            list.Page = page;
            list.Total = (totalRecords / rows) + 1;
            list.Records = rows;
            return list;
        }