Ejemplo n.º 1
0
        public Contact GetContactByEmail(string email)
        {
            var contactApi = new ContactApiController();
            var contact    = contactApi.GetByEmail(email);

            // Track this contact for personalised content
            HttpCookie cookie = new HttpCookie("PipelineContactId");

            cookie.Value   = contact.Id.ToString();
            cookie.Expires = DateTime.MaxValue;
            HttpContext.Current.Response.SetCookie(cookie);

            return(contact);
        }
 public void TestInitialize()
 {
     _contact = new ContactModel
     {
         ContactId = 1,
         Email     = "*****@*****.**",
         FirstName = "asd",
         LastName  = "der",
         Phone     = "1231231234",
         Status    = "Active"
     };
     _mockContactInfo = new Mock <IContactRepo>();
     _apiController   = new ContactApiController(_mockContactInfo.Object);
 }
Ejemplo n.º 3
0
        public Pipeline CreateOpportunity(string name, string email, string description, double amount = 0, int statusId = 0)
        {
            var contact = GetContactByEmail(email);

            if (contact == null)
            {
                contact.Name  = name;
                contact.Email = email;
            }
            contact = new ContactApiController().PostSave(contact);

            var pipeline = new Pipeline()
            {
                Name      = description,
                Value     = amount,
                StatusId  = statusId,
                ContactId = contact.Id
            };

            return(new PipelineApiController().PostSave(pipeline));
        }
Ejemplo n.º 4
0
        public Contact GetContactById(int id)
        {
            var contactApi = new ContactApiController();

            return(contactApi.GetById(id));
        }
Ejemplo n.º 5
0
        // deprecate further down...

        public Pipeline CreateNew(string name, string organisation, string email, string telephone, string subject, string comment, int nodeId = 0, double value = 0, int probability = 50, int statusId = 0, Dictionary <string, dynamic> customProps = null)
        {
            var newPipeline = new Pipeline();

            // we need at least name, email and organisation
            if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(email))
            {
                return(newPipeline);
            }

            var taskController     = new TaskApiController();
            var orgController      = new OrganisationApiController();
            var contactController  = new ContactApiController();
            var pipelineController = new PipelineApiController();

            int currentOrgId = 0;

            if (!string.IsNullOrEmpty(organisation))
            {
                // check if we have an org with that email, if not create one
                var currentOrg = orgController.GetByName(organisation);
                if (currentOrg == null)  // organisation is optional
                {
                    currentOrg = orgController.PostSave(new Organisation()
                    {
                        Id          = 0,
                        UserId      = 0,
                        Name        = organisation,
                        DateCreated = DateTime.Now,
                        Email       = email
                    });

                    currentOrgId = currentOrg.Id;
                }
            }

            // check if we have a member with that email, if not create one
            var contact = contactController.GetByEmail(email);

            if (contact == null)
            {
                var newContact = new Contact()
                {
                    Id = 0,
                    OrganisationIds = currentOrgId.ToString(),
                    Name            = name,
                    Telephone       = telephone,
                    Email           = email
                };
                contact = contactController.PostSave(newContact);
            }

            // install cookie for personalised content
            HttpCookie cookie = new HttpCookie("PipelineContactId");

            cookie.Value   = contact.Id.ToString();
            cookie.Expires = DateTime.MaxValue;
            HttpContext.Current.Response.SetCookie(cookie);

            //finally, create a new pipeline and note
            newPipeline = pipelineController.PostSave(new Pipeline()
            {
                Name           = subject,
                DateCreated    = DateTime.Now,
                StatusId       = statusId,
                OrganisationId = currentOrgId,
                ContactId      = contact.Id,
                Value          = value,
                DateComplete   = DateTime.Now,
                Probability    = probability, // todo: read from node
            });

            if (customProps != null)
            {
                newPipeline.UpdateProperties(customProps);
            }


            if (!String.IsNullOrEmpty(comment))
            {
                var newNote = taskController.PostSave(new GrowCreate.PipelineCRM.Models.Task()
                {
                    Description = comment,
                    PipelineId  = newPipeline.Id,
                    UserId      = -1
                });
            }
            return(newPipeline);
        }
Ejemplo n.º 6
0
 public void Initiate()
 {
     _contactApi = new ContactApiController();
 }