Example #1
0
        public ActionResult Index(string n)
        {
            //TODO REFACTOR get element in post data should be refactored
            pTwoLeft  = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtTwoLeft"));
            pAlphabet = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtAlphabet"));
            pThree    = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtThree"));
            pCityCode = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtCityCode"));
            patteNo   = Request.Form.Get(CommonUtilities.CorrectPostedElement("UUPlaque$txtPatteNo"));

            if (!IsPlaqueEnterd() && patteNo.IsNullOrWhiteSpace())
            {
                Session["Error"] = "برای دریافت اطلاعات پته، پلاک و یا شماره سریال پته را وارد نمایید.";
                return(RedirectToAction("Index", "Patte"));
            }

            JsonResultWithObject <Patte> response;

            if (IsPlaqueEnterd())
            {
                response = Logics.BitaServices.GetPatte(GetPlaqueCorrectFormat(), true);
            }
            else
            {
                if (patteNo.StartsWith("uwp"))
                {
                    JsonResultWithObject <Patte> uwPateResponse = Logics.BitaServices.GetUrbanWarehousePate(patteNo);
                    if (uwPateResponse.isSuccess)
                    {
                        Session["uwPate"] = uwPateResponse.result;
                        return(RedirectToAction("ShowUwPate", "Patte"));
                    }
                    Session["Error"] = uwPateResponse.messages[0];
                    return(RedirectToAction("Index", "Patte"));
                }
                response = Logics.BitaServices.GetPatte(patteNo, false);
            }
            if (response.isSuccess)
            {
                Session["patte"] = response.result;
//                JsonResultWithObject<customsValueDeclaration[]> result = Logics.BitaServices.CustomsValueDeclarationInformation(response.result.KotajNos.Split('*')[0]);
//                if (result.isSuccess)
//                {
//                    ICollection<Commodity> pateCommodities = response.result.Containers.ToList()[0].Commoditys;
//                    IQueryable<customsValueDeclaration> arzesh = result.result.ToList().AsQueryable().Where(v => pateCommodities.Any(c => c.CommodityHsCode.Equals(v.commodityHSCode)));
//                    arzesh.ForEach(a => a.commodityItemQuantity = pateCommodities.First(c => c.CommodityHsCode.Equals(a.commodityHSCode)).CommodityItemQuantity);
//                    arzesh.ForEach(a => a.commodityDescription = pateCommodities.First(c => c.CommodityHsCode.Equals(a.commodityHSCode)).CommodityTariffDescription);
//                    List<customsValueDeclaration> listArzesh = arzesh.DistinctBy(d=> d.commodityHSCode).ToList();
//                    Session["ValueDeclaration"] = listArzesh;
//                }
                return(RedirectToAction("ShowPatte", "Patte"));
            }
            else
            {
                Session["Error"] = response.messages[0];
                return(RedirectToAction("Index", "Patte"));
            }
        }