Пример #1
0
        public ActionResult UpdateUserFromCRM(int UserId, string firstname, string lastname, string emailid, string companyname, string jobtitle, string phone, string crmregid, string allowpost,
                                              string senioritylevel, string primaryjob, string natureofbusiness, string country, string topicofinterest, string registeredforglobal,
                                              bool checkbox1, bool checkbox2, bool checkbox3, bool checkbox4, bool iszoomevent, bool isbigmarkerevent)
        {
            try
            {
                var registeredUser = db.RegisteredUsers.Find(UserId);
                registeredUser.CRM_FirstName      = firstname;
                registeredUser.CRM_LastName       = lastname;
                registeredUser.CRM_EmaiId         = emailid;
                registeredUser.CRM_CompanyName    = companyname;
                registeredUser.CRM_JobTitle       = jobtitle;
                registeredUser.CRM_RegistrationId = crmregid;
                registeredUser.IsDeleted          = false;
                registeredUser.IsRegistered       = true;
                db.Entry(registeredUser).State    = EntityState.Modified;
                var allowuser        = db.Packages.Select(x => x.No_of_Registration).FirstOrDefault();
                var reguser          = db.RegisteredUsers.Where(x => x.EventId == registeredUser.EventId && x.Ispaid == true).Count();
                var events           = EventService.GetEventById(Convert.ToInt32(registeredUser.EventId));
                var availablecredits = CustomerService.GetCustomerAvailableCredit(events.CustomerId);
                if (availablecredits > 0)
                {
                    registeredUser.Ispaid = true;
                }
                else
                {
                    registeredUser.Ispaid = false;
                }
                db.SaveChanges();


                if (allowpost == "true" || allowpost == null || allowpost == "undefined")
                {
                    ShareOnWall(Convert.ToInt32(registeredUser.EventId), registeredUser.ProfileId, registeredUser.AuthToken, registeredUser.UserId);
                }

                if (iszoomevent)
                {
                    db.AddZoomUserDetails(0, registeredUser.EventId, registeredUser.UserId, senioritylevel, primaryjob, natureofbusiness, country,
                                          topicofinterest, registeredforglobal, checkbox1, checkbox2, checkbox3, checkbox4, null, null);

                    var zoomtoken = db.SpGetEventToken(events.EventId);
                    try
                    {
                        if (zoomtoken != null)
                        {
                            ZoomModel objZoomModel = new ZoomModel();
                            objZoomModel.id    = events.WebinarId;
                            objZoomModel.token = zoomtoken.FirstOrDefault();
                            objZoomModel.payload.first_name = registeredUser.FirstName;
                            objZoomModel.payload.last_name  = registeredUser.LastName;
                            objZoomModel.payload.email      = registeredUser.Email;
                            objZoomModel.payload.org        = registeredUser.Company;
                            objZoomModel.payload.phone      = phone;
                            objZoomModel.payload.country    = country;
                            var jsonbody = JsonConvert.SerializeObject(objZoomModel);
                            var client   = new RestClient("https://connect-zoom.eventnx.com/api/webinar/register");
                            client.Timeout = -1;
                            var request = new RestRequest(Method.PUT);
                            request.AddHeader("Content-Type", "application/json");
                            request.AddParameter("application/json", jsonbody, ParameterType.RequestBody);
                            IRestResponse <ZoomResponse> response = client.Execute <ZoomResponse>(request);
                            var zoomresponse = response.Data;
                            if (zoomresponse.token != null)
                            {
                                EventService.UpdateZoomTokenEvent(zoomresponse.token, events.CustomerId);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (isbigmarkerevent)
                {
                    db.AddBigMarkerUserDetails(0, registeredUser.EventId, registeredUser.UserId, senioritylevel, primaryjob, natureofbusiness, country,
                                               topicofinterest, registeredforglobal, checkbox1, checkbox2, checkbox3, checkbox4, null, null);

                    var zoomtoken = db.SpGetBigMarkerEventToken(events.EventId);
                    try
                    {
                        if (zoomtoken != null)
                        {
                            BigMarkerRequest bigMarkerModel = new BigMarkerRequest();
                            bigMarkerModel.Id                    = events.BigMarkerWebinairId;
                            bigMarkerModel.Token                 = zoomtoken.FirstOrDefault();
                            bigMarkerModel.Payload.FirstName     = registeredUser.FirstName;
                            bigMarkerModel.Payload.LastName      = registeredUser.LastName;
                            bigMarkerModel.Payload.Email         = registeredUser.Email;
                            bigMarkerModel.Payload.CustomFields  = "";
                            bigMarkerModel.Payload.UtmBmcrSource = registeredUser.Source;
                            bigMarkerModel.Payload.CustomUserId  = registeredUser.UserId.ToString();
                            var jsonbody = JsonConvert.SerializeObject(bigMarkerModel);
                            var client   = new RestClient("https://connect-zoom.eventnx.com/api/bigmarker/register");
                            client.Timeout = -1;
                            var request = new RestRequest(Method.PUT);
                            request.AddHeader("Content-Type", "application/json");
                            request.AddParameter("application/json", jsonbody, ParameterType.RequestBody);
                            IRestResponse <BigMarkerResponse> response = client.Execute <BigMarkerResponse>(request);
                            var bigmarkeresponse = response.Data;
                            if (bigmarkeresponse.Token != null)
                            {
                                EventService.UpdateBigMarkerTokenEvent(bigmarkeresponse.Token);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                return(Json(new { success = true, message = "saved Data successfully" }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    message = "Could not saved Data" + ex.ToString()
                }));
            }
        }