public ContactsDataTableModel Get() { var model = new ContactsDataTableModel(); var contacts = contactService.GetCandidateContacts(); var contactmodels = new HashSet <CandidateContactModel>(); foreach (var contact in contacts) { var candidate = new CandidateContactModel(); candidate.Id = contact.Id; candidate.FullName = contact.FullName; candidate.ActivityCount = contact.Activities.Count(); var lastActivity = contact.Activities.OrderByDescending(o => o.ActivityDate).FirstOrDefault(); if (lastActivity != null) { candidate.Staff = lastActivity.Staff.FullName; candidate.LastActivityDate = lastActivity.ActivityDate; candidate.NextStep = lastActivity.ActivityNextStep.Name; } contactmodels.Add(candidate); } model.Meta.Total = model.Data.Count(); model.Meta.Field = "fullName"; model.Data = contactmodels; return(model); }
public static tblContact ConvertTotblContact(this CandidateContactModel data) { return(new tblContact() { FirstName = data.FirstName, LastName = data.LastName, EmailAddress = data.EmailAddress, City = data.City, CountyID = Convert.ToInt64(data.CountyID), ID = data.ID, StateID = Convert.ToInt64(data.StateID), MobileNumber = data.MobileNumber, StreetAddress = data.StreetAddress, ZipCode = data.ZipCode, IsActive = data.isActive, IsDeleted = data.isDeleted ?? false, CreatedUserID = data.createdUserID, UpdatedUserID = data.updatedUserID, CreatedTimestamp = data.createdTimestamp ?? DateTime.Now, UpdatedTimestamp = data.updatedTimestamp ?? DateTime.Now }); }