public JsonResult SupportPhoneInstallation_Insert(AddSupportPhoneInstallationRequst request)
        {
            GeneralResponse response = new GeneralResponse();

            response = _supportPhoneInstallationService.AddSupportPhoneInstallation(request, GetEmployee().ID);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public GeneralResponse AddSupportPhoneInstallation(AddSupportPhoneInstallationRequst request,
                                                           Guid CreateemployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportPhoneInstallation supportPhoneInstallation = new SupportPhoneInstallation();
                supportPhoneInstallation.ID                         = Guid.NewGuid();
                supportPhoneInstallation.CreateDate                 = PersianDateTime.Now;
                supportPhoneInstallation.CreateEmployee             = _employeeRepository.FindBy(CreateemployeeID);
                supportPhoneInstallation.Comment                    = request.Comment;
                supportPhoneInstallation.InstallDate                = request.InstallDate;
                supportPhoneInstallation.Installed                  = request.Installed;
                supportPhoneInstallation.SendNotificationToCustomer = request.SendNotificationToCustomer;
                supportPhoneInstallation.Support                    = _supportRepository.FindBy(request.SupportID);
                supportPhoneInstallation.RowVersion                 = 1;


                SupportStatusRelation supportStatusRelation = _supportStatusRelationRepository.FindBy(request.SupportStatusID);
                supportPhoneInstallation.Support.SupportStatus          = _supportStatusRepository.FindBy(supportStatusRelation.RelatedSupportStatus.ID);
                supportPhoneInstallation.Support.Customer.SupportStatus = supportPhoneInstallation.Support.SupportStatus;


                if (supportPhoneInstallation.Support.SupportStatus.IsLastSupportState)
                {
                    supportPhoneInstallation.Support.Closed = true;
                }

                _supportPhoneInstallationRepository.Add(supportPhoneInstallation);
                _uow.Commit();

                #region Send SMS

                if (supportPhoneInstallation.Support.SupportStatus.SendSmsOnEnter)
                {
                    // Threading
                    SmsData smsData = new SmsData()
                    {
                        body = supportPhoneInstallation.Support.SupportStatus.SmsText, phoneNumber = supportPhoneInstallation.Support.Customer.Mobile1
                    };
                    Thread oThread = new Thread(SendSmsVoid);
                    oThread.Start(smsData);
                }

                #endregion
            }
            catch (Exception ex)
            {
                response.ErrorMessages.Add(ex.Message);
                if (ex.InnerException != null)
                {
                    response.ErrorMessages.Add(ex.InnerException.Message);
                }
            }

            return(response);
        }