Esempio n. 1
0
        public virtual ActionResult GetProducts(Guid id)
        {
            var declarant = expRepo.GetAssessmentDeclaration(id);

            if (declarant == null)
            {
                return(Json(new { isSuccess = false }));
            }

            //есть ли результат
            var obkStageExpDocumentResult = new SafetyAssessmentRepository().GetStageExpDocumentResult(declarant.Id);

            if (obkStageExpDocumentResult != null)
            {
                // если результат положительный
                if (obkStageExpDocumentResult.ExpResult)
                {
                    var results = new List <OBK_Procunts_Series>();
                    foreach (var product in declarant.OBK_Contract.OBK_RS_Products)
                    {
                        foreach (var productSeries in product.OBK_Procunts_Series)
                        {
                            var series = new OBK_Procunts_Series();
                            series.Id              = productSeries.Id;
                            series.Series          = productSeries.Series;
                            series.SeriesStartdate = productSeries.SeriesStartdate;
                            DateTime endDate       = new DateTime();
                            var      validDate     = DateTime.TryParse(productSeries.SeriesEndDate, out endDate);
                            var      endDateString = productSeries.SeriesEndDate;
                            if (validDate == true)
                            {
                                endDate       = endDate.AddMonths(1);
                                endDateString = endDate.ToString("dd.MM.yyyy");
                            }
                            series.SeriesEndDate     = endDateString;
                            series.SeriesParty       = productSeries.SeriesParty;
                            series.SeriesShortNameRu = productSeries.sr_measures.short_name;
                            series.SeriesNameRu      = productSeries.Series + ", годен до " + endDateString +
                                                       ", партия " + productSeries.SeriesParty + " " +
                                                       productSeries.SeriesShortNameRu;

                            series.NameRu         = product.NameRu;
                            series.NameKz         = product.NameKz;
                            series.ProducerNameRu = product.ProducerNameRu;
                            series.ProducerNameKz = product.ProducerNameKz;
                            series.CountryNameRu  = product.CountryNameRu;
                            series.CountryNameKz  = product.CountryNameKZ;

                            var obkStageExpDocumentSeries =
                                new SafetyAssessmentRepository().GetStageExpDocument(productSeries.Id);
                            if (obkStageExpDocumentSeries != null)
                            {
                                series.ExpId           = obkStageExpDocumentSeries.Id;
                                series.ProductSeriesId = obkStageExpDocumentSeries.ProductSeriesId;
                                series.ExpResult       = obkStageExpDocumentSeries.ExpResult ? "True" : "False";
                                series.ExpResultTitle  = obkStageExpDocumentSeries.ExpResult
                                    ? "Соответствует требованиям"
                                    : "Не соответствует требованиям";
                                series.ExpStartDate =
                                    string.Format("{0:dd.MM.yyyy}", obkStageExpDocumentSeries.ExpStartDate);
                                series.ExpEndDate            = endDateString;
                                series.ExpReasonNameRu       = obkStageExpDocumentSeries.ExpReasonNameRu;
                                series.ExpReasonNameKz       = obkStageExpDocumentSeries.ExpReasonNameKz;
                                series.ExpProductNameRu      = obkStageExpDocumentSeries.ExpProductNameRu;
                                series.ExpProductNameKz      = obkStageExpDocumentSeries.ExpProductNameKz;
                                series.ExpProductShortNameRu = obkStageExpDocumentSeries.ExpProductShortNameRu;
                                series.ExpProductShortNameKz = obkStageExpDocumentSeries.ExpProductShortNameKz;
                                series.ExpNomenclatureRu     = obkStageExpDocumentSeries.ExpNomenclatureRu;
                                series.ExpNomenclatureKz     = obkStageExpDocumentSeries.ExpNomenclatureKz;
                                series.ExpAddInfoRu          = assessmentRepo.FormExpAdditionalInfo(declarant);
                                series.ExpAddInfoKz          = assessmentRepo.FormExpAdditionalInfo(declarant, true);
                                series.ExpConclusionNumber   = obkStageExpDocumentSeries.ExpConclusionNumber;
                                series.ExpBlankNumber        = obkStageExpDocumentSeries.ExpBlankNumber;
                                series.ExpApplication        = obkStageExpDocumentSeries.ExpApplication;
                                series.ExpApplicationNumber  = obkStageExpDocumentSeries.ExpApplicationNumber;
                            }
                            else
                            {
                                series.ExpConclusionNumber = expRepo.GenerateNumber(id, productSeries.Id);
                            }
                            results.Add(series);
                        }
                    }
                    return(Json(new { isSuccess = true, results }));
                }
                else
                {
                    var obkStageExpDocumentSeries =
                        new SafetyAssessmentRepository().GetStageExpDocument(declarant.Id);
                    if (obkStageExpDocumentSeries != null)
                    {
                        var series = new OBK_Procunts_Series();
                        series.ExpId           = obkStageExpDocumentSeries.Id;
                        series.ProductSeriesId = obkStageExpDocumentSeries.ProductSeriesId;
                        series.ExpResult       = obkStageExpDocumentSeries.ExpResult ? "True" : "False";
                        series.ExpResultTitle  = obkStageExpDocumentSeries.ExpResult
                            ? "Соответствует требованиям"
                            : "Не соответствует требованиям";
                        series.ExpStartDate =
                            string.Format("{0:dd.MM.yyyy}", obkStageExpDocumentSeries.ExpStartDate);
                        series.ExpEndDate =
                            string.Format("{0:dd.MM.yyyy}", obkStageExpDocumentSeries.ExpEndDate);
                        series.ExpReasonNameRu      = obkStageExpDocumentSeries.ExpReasonNameRu;
                        series.ExpReasonNameKz      = obkStageExpDocumentSeries.ExpReasonNameKz;
                        series.ExpProductNameRu     = obkStageExpDocumentSeries.ExpProductNameRu;
                        series.ExpProductNameKz     = obkStageExpDocumentSeries.ExpProductNameKz;
                        series.ExpNomenclatureRu    = obkStageExpDocumentSeries.ExpNomenclatureRu;
                        series.ExpNomenclatureKz    = obkStageExpDocumentSeries.ExpNomenclatureKz;
                        series.ExpAddInfoRu         = obkStageExpDocumentSeries.ExpAddInfoRu;
                        series.ExpAddInfoKz         = obkStageExpDocumentSeries.ExpAddInfoKz;
                        series.ExpConclusionNumber  = obkStageExpDocumentSeries.ExpConclusionNumber;
                        series.ExpBlankNumber       = obkStageExpDocumentSeries.ExpBlankNumber;
                        series.ExpApplication       = obkStageExpDocumentSeries.ExpApplication;
                        series.ExpApplicationNumber = obkStageExpDocumentSeries.ExpApplicationNumber;

                        return(Json(new { isSuccess = true, series }));
                    }
                    return(Json(new { isSuccess = true }));
                }
            }
            return(Json(new { isSuccess = true }));
        }