コード例 #1
0
 public ActionResult AddContact(CreateContactRequest model)
 {
     model.UserId  = SynergySecurity.GetCurrentUser();
     model.Api     = ApiTypes.AgileCrm;
     model.Request = "Create New Contact";
     contactApi.AddContact(model);
     return(RedirectToAction("Contacts"));
 }
コード例 #2
0
        public ActionResult ContactDelete(long id, FormCollection collection)
        {
            var request = new DeleteContactRequest(SynergySecurity.GetCurrentUser());

            request.Id = id;
            var RecordId = SynergySecurity.ToLog <DeleteContactRequest>(request);
            DeleteContactResponse response = contactApi.DeleteContact(request);

            SynergySecurity.ToUpdateLog <DeleteContactResponse>(response, RecordId);
            return(RedirectToAction("Contacts"));
        }
コード例 #3
0
        public ActionResult EditContact(UpdateContactRequest model)
        {
            model.UserId  = SynergySecurity.GetCurrentUser();
            model.Api     = ApiTypes.AgileCrm;
            model.Request = "Update Contact details";
            var RecordId = SynergySecurity.ToLog <UpdateContactRequest>(model);
            UpdateContactResponse response = contactApi.UpdateContactProperty(model);

            SynergySecurity.ToUpdateLog <UpdateContactResponse>(response, RecordId);
            return(RedirectToAction("Contacts"));
        }
コード例 #4
0
        public ActionResult Contacts()
        {
            var request  = new GetContactsRequest(SynergySecurity.GetCurrentUser());
            var RecordId = SynergySecurity.ToLog <GetContactsRequest>(request);
            var contacts = contactApi.GetContacts(request);

            SynergySecurity.ToUpdateLog <GetContactsResponse>(contacts, RecordId);
            var model = ToUpdateContactRequestList(contacts);

            return(View("ContactList", model));
        }
コード例 #5
0
        public ActionResult ContactDelete(long id)
        {
            UpdateContactRequest request = null;
            var getRequest = new GetContactRequest(SynergySecurity.GetCurrentUser());

            getRequest.Id = id;
            var RecordId = SynergySecurity.ToLog <GetContactRequest>(getRequest);
            var model    = contactApi.GetContact(getRequest);

            SynergySecurity.ToUpdateLog <GetContactResponse>(model, RecordId);
            if (model != null)
            {
                request = new UpdateContactRequest()
                {
                    Id       = model.Contact.id,
                    Property = ToConvertContactProperty(model.Contact)
                };
            }
            return(View(request ?? new UpdateContactRequest()));
        }
コード例 #6
0
        public void AgileCrmInit(ref ContactApi contactApi, ref DealApi dealApi)
        {
            using (var ctx = new SynergyDbContext())
            {
                var userId = SynergySecurity.GetCurrentUser();

                var apiConfiguration = ctx.Synergy_ApiConfigurations.
                                       Where(x => x.UserId == userId && x.IsActive).FirstOrDefault();
                if (apiConfiguration != null)
                {
                    contactApi = new ContactApi(agileKey: apiConfiguration.Key, agileEmail: apiConfiguration.Email, agileUrl: apiConfiguration.Url);
                    dealApi    = new DealApi(agileKey: apiConfiguration.Key, agileEmail: apiConfiguration.Email, agileUrl: apiConfiguration.Url);
                }
                else
                {
                    contactApi = new ContactApi();
                    dealApi    = new DealApi();
                }
            }
        }