Пример #1
0
        public JsonResult SupportQc_Insert(AddSupportQcRequest request)
        {
            GeneralResponse response = new GeneralResponse();

            //AddSupportQcRequest request=new AddSupportQcRequest();
            //request.Comment = "این یک توضیح است برا ی کیو سی";
            //request.ExpertBehavior = 1;
            //request.ExpertCover = 2;
            //request.InputTime = "12:20";
            //request.InstallerEmployeeID = Guid.Parse("12D942E9-9B2F-42A9-82D5-66D661FAC17D");
            //request.OutputTime="14:50";
            //request.RecivedCost = 230000;
            //request.SaleAndService = 1;
            //request.SendNotificationToCustomer = true;
            //request.SendNotificationToMaster = true;
            //request.SupportID = Guid.Parse("AC57D46B-5139-4F03-B4D4-4A75B747CDCA");


            response = _supportQcService.AddSupportQc(request, GetEmployee().ID);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public GeneralResponse AddSupportQc(AddSupportQcRequest request, Guid CreateEmployeeID)
        {
            GeneralResponse response = new GeneralResponse();

            try
            {
                SupportQc supportQc = new SupportQc();

                supportQc.ID             = Guid.NewGuid();
                supportQc.CreateDate     = PersianDateTime.Now;
                supportQc.CreateEmployee = _employeeRepository.FindBy(CreateEmployeeID);
                supportQc.Comment        = request.Comment;
                supportQc.ExpertBehavior = (SupportQc.State)request.ExpertBehavior;
                supportQc.ExpertCover    = (SupportQc.State)request.ExpertCover;
                supportQc.InputTime      = request.InputTime;
                if (string.IsNullOrEmpty(request.Comment))
                {
                    response.ErrorMessages.Add("افزودن توضیحات به فرم الزامیست.");
                    return(response);
                }
                supportQc.OutputTime                 = request.OutputTime;
                supportQc.RecivedCost                = request.RecivedCost;
                supportQc.SaleAndService             = (SupportQc.State)request.SaleAndService;
                supportQc.SendNotificationToCustomer = request.SendNotificationToCustomer;
                supportQc.SendNotificationToMaster   = request.SendNotificationToMaster;
                supportQc.RowVersion                 = 1;

                supportQc.Support = _supportRepository.FindBy(request.SupportID);


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

                if (supportQc.Support.SupportQc.Count() > 0)
                {
                    response.ErrorMessages.Add("برای هر پشتیبانی بیش از یک فرم QC نمیتوانید ثبت کنید");
                    return(response);
                }

                #endregion

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

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

                _supportQcRepository.Add(supportQc);
                _uow.Commit();

                #region Send SMS

                if (supportQc.Support.SupportStatus.SendSmsOnEnter)
                {
                    // Threading
                    SmsData smsData = new SmsData()
                    {
                        body = supportQc.Support.SupportStatus.SmsText, phoneNumber = supportQc.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);
        }