public async Task <IActionResult> ContactOwner(TestDriveViewModel model)
        {
            var receiver = await this.ads.GetAdOwnerEmail(model.ReceiverId);

            if (receiver == null)
            {
                this.ShowNotification(NotificationMessages.InvalidOperation);
                return(RedirectToAction(nameof(Details), new { id = model.ReceiverId }));
            }
            await this.emailSender.SendEmailAsync(model.Email, receiver, model.Subject, model.Message);

            this.ShowNotification(NotificationMessages.EmailSentSuccessfully, NotificationType.Success);
            return(RedirectToAction(nameof(Details), new { id = model.ReceiverId }));
        }
Exemplo n.º 2
0
        public async void CreateLead(TestDriveViewModel request, Guid?userid)
        {
            try
            {
                var createEntity = new CrmExecuteEntity("lead", Guid.NewGuid());

                createEntity.Attributes.Add("lastname", request.mcs_fullname);
                createEntity.Attributes.Add("mobilephone", request.mcs_mobilephone);

                if (!string.IsNullOrEmpty(request.mcs_dealerid))
                {
                    createEntity.Attributes.Add("mcs_dealerid", new CrmEntityReference("mcs_dealer", Guid.Parse(request.mcs_dealerid)));
                }

                #region 用户行为赋值
                var fetchString  = _Repository.GetDriveBehavior("test_drive_appointment");
                var fetchXdoc    = XDocument.Parse(fetchString);
                var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage()
                {
                    EntityName = "mcs_behavior",
                    FetchXml   = fetchXdoc
                };
                var fetchResponse = await _crmService.Execute(fetchRequest);

                var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage;
                var queryResult         = new QueryResult <CrmEntity>();
                queryResult.Results = fetchResponseResult.Value.Results;
                var mcs_behaviorid = queryResult.Results[0].Id;
                createEntity.Attributes.Add("mcs_behaviorid", new CrmEntityReference("mcs_behavior", mcs_behaviorid));
                #endregion

                var entityId = await _crmService.Create(createEntity, userid);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建试乘试驾预约
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <ValidateResult <CrmEntity> > CreateTestDrive(TestDriveViewModel request)
        {
            var validateResult = new ValidateResult <CrmEntity>();
            var userInfo       = ContextContainer.GetValue <UserInfo>(ContextExtensionTypes.CurrentUserInfo);

            try
            {
                Guid             mcs_driverecordid = string.IsNullOrEmpty(request.mcs_driverecordid) ? Guid.NewGuid() : Guid.Parse(request.mcs_driverecordid);
                CrmExecuteEntity Entity            = new CrmExecuteEntity("mcs_driverecord", mcs_driverecordid);

                if (!string.IsNullOrEmpty(request.mcs_fullname))
                {
                    Entity.Attributes.Add("mcs_fullname", request.mcs_fullname);
                }

                if (!string.IsNullOrEmpty(request.mcs_mobilephone))
                {
                    Entity.Attributes.Add("mcs_mobilephone", request.mcs_mobilephone);
                }
                if (!string.IsNullOrEmpty(request.mcs_carmodel))
                {
                    Entity.Attributes.Add("mcs_carmodel", new CrmEntityReference("mcs_carmodel", Guid.Parse(request.mcs_carmodel)));
                }
                if (!string.IsNullOrEmpty(request.mcs_businesstype))
                {
                    Entity.Attributes.Add("mcs_businesstype", request.mcs_businesstype);
                }
                if (!string.IsNullOrEmpty(request.mcs_dealerid))
                {
                    Entity.Attributes.Add("mcs_dealerid", new CrmEntityReference("mcs_dealer", Guid.Parse(request.mcs_dealerid)));
                }

                if (request.mcs_ordertime.HasValue)
                {
                    Entity.Attributes.Add("mcs_ordertime", request.mcs_ordertime.Value);
                }
                if (!string.IsNullOrEmpty(request.mcs_testdrivetime))
                {
                    Entity.Attributes.Add("mcs_testdrivetime", new CrmEntityReference("mcs_reservationconfiguration", Guid.Parse(request.mcs_testdrivetime)));
                }
                if (!string.IsNullOrEmpty(request.UserId))
                {
                    Entity.Attributes.Add("mcs_userid", request.UserId);
                }

                if (!string.IsNullOrEmpty(request.mcs_driverecordid))
                {
                    await _crmService.Update(Entity, userInfo?.systemuserid);
                }
                else
                {
                    mcs_driverecordid = await _crmService.Create(Entity, userInfo?.systemuserid);

                    //预约成功后 进行留资
                    if (mcs_driverecordid != null)
                    {
                        CreateLead(request, userInfo?.systemuserid);
                    }
                }

                validateResult.Result      = true;
                validateResult.Description = "操作成功";
            }
            catch (Exception ex)
            {
                validateResult.Result      = false;
                validateResult.Description = "操作失败,原因:" + ex.Message;
                throw ex;
            }


            return(validateResult);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 创建试乘试驾预约
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <ValidateResult <CrmEntity> > CreateTestDrive(TestDriveViewModel request)
 {
     return(await _testDriveService.CreateTestDrive(request));
 }
Exemplo n.º 5
0
        public async Task <NewtonsoftJsonActionResult <ValidateResult <CrmEntity> > > CreateTestDrive(TestDriveViewModel request)
        {
            var result = await app.CreateTestDrive(request);

            return(result);
        }