Exemplo n.º 1
0
        public ActionResult Details(FormCollection form)
        {
            string errorMessage;

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            bool isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage) && DateTimeHelper.TryParseMobileSafariDates(form, out errorMessage);
            var  data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            long key       = long.Parse(Session["IdfCase"].ToString());
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, key, null);

            var cloneHumanCase = (HumanCase)humanCase.Clone();

            m_Validation          = null;
            humanCase.Validation += hc_ValidationDetails;
            humanCase.ParseFormCollection(form);
            if (m_Validation != null)
            {
                humanCase.Validation -= hc_ValidationDetails;
                errorMessage          = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                HumanCase.Accessor acc = HumanCase.Accessor.Instance(null);
                acc.Validate(manager, humanCase, true, true, true);
                if (m_Validation == null)
                {
                    acc.Post(manager, humanCase);
                }
            }
            humanCase.Validation -= hc_ValidationDetails;
            if (m_Validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                data = humanCase.Compare(cloneHumanCase);
            }
            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 2
0
        public ActionResult StoreCase(FormCollection form)
        {
            var key = Int64.Parse(Session["IdfCase"].ToString());

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            var    vetCase = (VetCase)ModelStorage.Get(Session.SessionID, key, null);
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            bool isNumericValid = NumericHelper.TryParseInteger(form, out errorMessage);

            if (!isNumericValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            m_validation        = null;
            vetCase.Validation += vc_ValidationDetails;
            vetCase.ParseFormCollection(form);
            if (m_validation != null)
            {
                vetCase.Validation -= vc_ValidationDetails;
                errorMessage        = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Exemplo n.º 3
0
        public ActionResult Details(FormCollection form)
        {
            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            bool isNumericValid = NumericHelper.TryParseInteger(form, out errorMessage);

            if (!isNumericValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            long key     = long.Parse(Session["IdfCase"].ToString());
            var  vetCase = (VetCase)ModelStorage.Get(Session.SessionID, key, null);

            #region Обработка FF
            //TODO:
            #endregion

            m_validation        = null;
            vetCase.Validation += vc_ValidationDetails;
            vetCase.ParseFormCollection(form);
            if (m_validation != null)
            {
                vetCase.Validation -= vc_ValidationDetails;
                errorMessage        = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                VetCase.Accessor acc = VetCase.Accessor.Instance(null);
                acc.Validate(manager, vetCase, true, true, true);
                if (m_validation == null)
                {
                    acc.Post(manager, vetCase);
                }
            }
            vetCase.Validation -= vc_ValidationDetails;
            if (m_validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                ModelStorage.Remove(Session.SessionID, vetCase.idfCase, m_FarmTreeSessionKey);
            }

            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }