public JsonResult SpportDeliverService_Insert(AddSupportDeliverServiceRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            //AddSupportDeliverServiceRequest request=new AddSupportDeliverServiceRequest();
            //request.AmountRecived = 200000;
            //request.DeliverDate = "1393/02/29";
            //request.TimeInput = "20:30";
            //request.TimeOutput = "22:30";
            //request.Comment = "توضیحات نصب در این قسمت وارد میشود";
            //request.SendNotificationToCustomer = true;
            //request.SupportID = Guid.Parse("AC57D46B-5139-4F03-B4D4-4A75B747CDCA");


            response = _supportDeliverServiceService.AddSeupportDeliverService(request, GetEmployee().ID);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
        public GeneralResponse AddSeupportDeliverService(AddSupportDeliverServiceRequest request, Guid CreateEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportDeliverService supportDeliverService = new SupportDeliverService();

                supportDeliverService.ID             = Guid.NewGuid();
                supportDeliverService.DeliverDate    = request.DeliverDate;
                supportDeliverService.TimeInput      = request.TimeInput;
                supportDeliverService.TimeOutput     = request.TimeOutput;
                supportDeliverService.AmountRecived  = request.AmountRecived;
                supportDeliverService.Comment        = request.Comment;
                supportDeliverService.CreateDate     = PersianDateTime.Now;
                supportDeliverService.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID);
                supportDeliverService.RowVersion     = 1;
                supportDeliverService.Support        = _supportRepository.FindBy(request.SupportID);

                #region چک کردن عدم وجود مورد ثبت شده

                if (supportDeliverService.Support.SupportDeliverService.Count() > 0)
                {
                    response.ErrorMessages.Add("برای هر پشتیبانی بیش از یک تحویل سرویس نمیتوانید ثبت کنید");
                    return(response);
                }

                #endregion

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

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

                _supportDeliverServiceRepository.Add(supportDeliverService);

                #region Send SMS

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

                #endregion

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

            return(response);
        }