Exemplo n.º 1
0
		//public void SaveRecipients(List<string> users, List<int> leads, int activityID)
		//{
		//  using (var dc = new EngageCCTDataClassesDataContext())
		//  {
		//    if (users.Count > 0)
		//    {
		//      foreach (var user in users)
		//      {
		//        T_ActivityUserInformation tActivityUserInformation = new T_ActivityUserInformation();
		//        tActivityUserInformation.ActivityID = activityID;
		//        tActivityUserInformation.Login = user;
		//        dc.T_ActivityUserInformations.InsertOnSubmit(tActivityUserInformation);
		//        dc.SubmitChanges();
		//      }
		//    }

		//    if (leads.Count > 0)
		//    {
		//      foreach (var lead in leads)
		//      {
		//        T_ActivityLead tActivityLead = new T_ActivityLead();
		//        tActivityLead.ActivityID = activityID;
		//        tActivityLead.LeadID = lead;
		//        dc.T_ActivityLeads.InsertOnSubmit(tActivityLead);
		//        dc.SubmitChanges();
		//      }
		//    }

		//  }
		//}

		public List<Priority> GetPriorities()
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				List<Priority> list = new List<Priority>();
				var query = dc.T_Priorities.AsQueryable();
				foreach (var item in query)
				{
					Priority priority = new Priority();
					priority.PriorityID = item.PriorityID;
					priority.Type = item.prType;
					list.Add(priority);
				}
				return list;
			}
		}
Exemplo n.º 2
0
		private static Activity GetActivityEntity(T_Activity tActivity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				UserInformation createdBy = new UserInformation { FirstName = tActivity.T_UserInformation.usrFirstName, LastName = tActivity.T_UserInformation.usrLastName, Login = tActivity.T_UserInformation.Login };
				UserInformation owner = new UserInformation { FirstName = tActivity.T_UserInformation1.usrFirstName, LastName = tActivity.T_UserInformation1.usrLastName, Login = tActivity.T_UserInformation1.Login };
				UserInformation sender = new UserInformation { FirstName = tActivity.T_UserInformation2.usrFirstName, LastName = tActivity.T_UserInformation2.usrLastName, Login = tActivity.T_UserInformation2.Login };

				var tActivityLeads = dc.T_ActivityLeads.Where(al => al.ActivityID == tActivity.ActivityID);
				var tLeads = dc.T_Leads.Where(l => tActivityLeads.Any(ac => ac.LeadID == l.LeadID));
				CCTLeadProvider leadProvider = new CCTLeadProvider();
				List<Lead> recipients = new List<Lead>();
				foreach (var lead in tLeads)
				{
					var recipient = leadProvider.GetLeadEntity(lead);
					recipients.Add(recipient);
				}

				Priority priority = new Priority { PriorityID = tActivity.T_Priority.PriorityID, Type = tActivity.T_Priority.prType };
				ActivityType activityType = new ActivityType { Type = tActivity.T_ActivityType.atType, TypeID = tActivity.T_ActivityType.TypeID };

				DateTime createdDate = tActivity.actCreationDate;
				DateTime? dueDate = tActivity.actDue;

				List<Note> notes = new List<Note>();
				var tActivityNotes = dc.T_ActivityNotes.Where(e => e.ActivityID == tActivity.ActivityID);
				foreach (var tActivityNote in tActivityNotes)
				{
					notes.Add(leadProvider.GetNoteEntity(tActivityNote.T_Note));
				}


				//Activity activity = new Activity()
				//{
				//  ActivityID = tActivity.ActivityID,
				//  CreatedBy = createdBy,
				//  ActivityType = activityType,
				//  CreatedOn = createdDate,
				//  Due = dueDate,
				//  Notes = notes,
				//  Owner = owner,
				//  Post = tActivity.actPost,
				//  Priority = priority,
				//  Recipient = recipient,
				//  Sender = sender,
				//  Subject = tActivity.actSubject
				//};

				ActivityStatus status = new ActivityStatus();
				status.StatusID = tActivity.StatusID;
				var stat = dc.T_ActivityStatus.Where(st => st.StatusID == status.StatusID).Select(s => s.asStatus).First();
				status.Status = stat;
				Activity activity = new Activity();
				activity.ActivityID = tActivity.ActivityID;
				activity.CreatedBy = createdBy;
				activity.ActivityType = activityType;
				activity.CreatedOn = createdDate;
				activity.Due = dueDate;
				activity.Notes = notes;
				activity.Owner = owner;
				activity.Post = tActivity.actPost;
				activity.Priority = priority;
				activity.Recipient = recipients;
				activity.Sender = sender;
				activity.Subject = tActivity.actSubject;
				activity.Status = status;

				if (tActivity.actPhone != null)
				{
					activity.Phone = tActivity.actPhone;
				}
				if (tActivity.actAddress != null)
				{
					activity.Address = tActivity.actAddress;
				}

				return activity;
			}
		}