Beispiel #1
0
        public ActionResult EditAjax([DataSourceRequest] DataSourceRequest request, PriceQuotationDetailViewModel item)
        {
            if (ModelState.IsValid)
            {
                List <TransportBidQuotation> existing =
                    _bidQuotationService.FindBy(t => t.BidID == item.BidID &&
                                                t.TransporterID == item.TransporterID &&
                                                t.SourceID == item.SourceID &&
                                                t.DestinationID == item.DestinationID
                                                );
                var edited = new TransportBidQuotation();
                if (existing.Count == 1)
                {
                    edited = existing[0];
                }
                //                    transportQuote.TransportBidQuotationID = edited.TransportBidQuotationID;
                edited.Tariff   = item.Tariff;
                edited.Remark   = item.Remark;
                edited.Position = item.Rank;
                edited.IsWinner = item.IsWinner;

                edited.TransporterID = item.TransporterID;
                edited.SourceID      = item.SourceID;
                edited.DestinationID = item.DestinationID;
                edited.BidID         = item.BidID;

                // edited.
                if (existing.Count == 1)
                {
                    _bidQuotationService.UpdateTransportBidQuotation(edited);
                }
                else
                {
                    _bidQuotationService.AddTransportBidQuotation(edited);
                }
                return(Json(new[] { item }.ToDataSourceResult(request, ModelState)));
            }
            return(Json("{}", JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        //[ProcurementAuthorize(operation = ProcurementCheckAccess.Operation.Bid_Planning)]
        public ActionResult SaveBidProposals([DataSourceRequest] DataSourceRequest request, List <PriceQuotationDetail> models)
        {
            foreach (PriceQuotationDetail bidProposal in models)
            {
                if (bidProposal != null && ModelState.IsValid)
                {
                    //var detail = _transportBidQuotationService.FindById(bidProposal.TransportBidQuotationID);
                    var detai = _transportBidQuotationService.FindBy(t =>
                                                                     t.BidID == bidProposal.BidID &&
                                                                     t.SourceID == bidProposal.SourceID &&
                                                                     t.DestinationID == bidProposal.DestinationID &&
                                                                     t.TransporterID == bidProposal.TransporterID);
                    var detail = detai.FirstOrDefault();

                    if (detail != null)
                    {
                        //detail.TransportBidQuotationID = bidProposal.TransportBidQuotationID;
                        detail.BidID = bidProposal.BidID;
                        detail.TransportBidQuotationHeaderID = bidProposal.HeaderId;
                        detail.TransporterID = bidProposal.TransporterID;
                        detail.SourceID      = bidProposal.SourceID;
                        detail.DestinationID = bidProposal.DestinationID;
                        detail.Tariff        = bidProposal.Tariff;
                        detail.Remark        = bidProposal.Remark ?? String.Empty;
                        detail.IsWinner      = false;
                        try
                        {
                            _transportBidQuotationService.UpdateTransportBidQuotation(detail);
                        }
                        catch (Exception e) { }
                    }

                    else
                    {
                        var newProposal = new TransportBidQuotation();
                        //newProposal.TransportBidQuotationID = bidProposal.TransportBidQuotationID;
                        newProposal.BidID = bidProposal.BidID;
                        newProposal.TransportBidQuotationHeaderID = bidProposal.HeaderId;
                        newProposal.TransporterID = bidProposal.TransporterID;
                        newProposal.SourceID      = bidProposal.SourceID;
                        newProposal.DestinationID = bidProposal.DestinationID;
                        newProposal.Tariff        = bidProposal.Tariff;
                        newProposal.Remark        = bidProposal.Remark ?? String.Empty;
                        newProposal.IsWinner      = false;
                        try
                        {
                            _transportBidQuotationService.AddTransportBidQuotation(newProposal);
                        }
                        catch (Exception e) { }
                    }

                    //int region = _adminUnitService.FindById(bidProposal.DestinationID).AdminUnit2.AdminUnit2.AdminUnitID;
                    //var changeable = _transportBidQuotationService.FindBy(t =>
                    //                                                     t.BidID == bidProposal.BidID);


                    //foreach (var transportBidQuotation in changeable)
                    //{
                    //    transportBidQuotation.IsWinner = false;
                    //    _transportBidQuotationService.UpdateTransportBidQuotation(transportBidQuotation);
                    //}
                }
            }
            return(Json(models.ToDataSourceResult(request, ModelState)));
        }