public ActionResult SearchByPasgah()
        {
            //TODO
            string pasgahName = Request.Form["ctl00$MainContent$Pasgah"];
            int    pasgahId   = PasgahHelper.GetAllPasgahNamesAndID(PasgahRepository.GetInstance().GetAllPasgahs())[pasgahName];

            try
            {
                List <ConfirmedPatte> result = ConfirmedPatteRepository.GetInstance().FindByPasgahId(pasgahId);
                if (result != null && result.Count > 0)
                {
                    Session["allConfirmationForPasgah"] = result;
                    return(RedirectToAction("ByPasgah", "ConfirmationReport"));
                }
                Session["Error"] = "هیچ تاییدیه ای در این مرکز ثبت نشده است.";
                return(RedirectToAction("ByPasgah", "ConfirmationReport"));
            }
            catch (EntityNotFoundException ex)
            {
                Session["Error"] = ex.Message;
                return(RedirectToAction("ByPasgah", "ConfirmationReport"));
            }
            catch (Exception ex)
            {
                Log.Error("در هنگام گزارش گیری بر اساس مرکز استعلام خطای نامشخص رخ داده است.", ex);
                Session["Information"] = "خطای داخلی رخ داده است.";
                return(RedirectToAction("MessagePage", "Default"));
            }
        }
Esempio n. 2
0
        public JsonResultWithObject <Patte> Get(string hexPelaq, string hexPasgah)
        {
            string plaq       = CommonUtilities.HexStringToString(hexPelaq, Encoding.UTF8);
            string pasgahName = CommonUtilities.HexStringToString(hexPasgah, Encoding.UTF8);
            Pasgah pasgah     = PasgahRepository.GetInstance().FindByName(pasgahName);
            JsonResultWithObject <Patte> response = Logics.BitaServices.GetPatte(plaq, true);

            if (!response.isSuccess)
            {
                return(response);
            }
            try
            {
                bool isSucceed =
                    ConfirmedPatteRepository.GetInstance()
                    .CheckIfNotRedundant(pasgah.Id, response.result.Id);
                if (isSucceed)
                {
                    isSucceed = ConfirmedPatteRepository.GetInstance().Save(new ConfirmedPatte()
                    {
                        PasgahID = pasgah.Id, PatteID = response.result.Id, UserID = pasgah.Users.FirstOrDefault().Id, ConfirmationIp = "WEB SERVICE"
                    });
                    if (isSucceed)
                    {
                        response.messages = new [] { "پته با موفقیت تایید شد." };
                    }
                    else
                    {
                        response.messages  = new[] { "در ذخیره سازی تاییدیه پته خطا رخ داده است." };
                        response.isSuccess = false;
                    }
                }
                else
                {
                    response.messages  = new[] { "این پته قبلا در این مرکز ثبت شده است و امکان تایید مجدد آن وجود ندارد." };
                    response.isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Uknown Error occured during saving patteConfirm with plaq {0}", plaq));
                Log.Error(ex.Message);

                response.messages  = new[] { "این پته قبلا در این مرکز ثبت شده است و امکان تایید مجدد آن وجود ندارد" };
                response.isSuccess = false;
            }

            return(response);
        }