Exemplo n.º 1
0
        public ActionResult AddEdit(string ien, string dfn, string pien, string itemType)
        {
            // *** Edit existing provider or facility ***

            NonVACareItemAddEdit model = new NonVACareItemAddEdit();

            // *** Values used to return after managing ***
            model.CurrentPatientDfn   = dfn;
            model.CurrentPregnancyIen = pien;
            model.CurrentItemType     = itemType;

            if (!string.IsNullOrWhiteSpace(ien))
            {
                // *** Get the item ***
                NonVACareItemsResult result = this.DashboardRepository.NonVACare.GetItem(ien);

                // *** Check for success ***
                if (result.Success)
                {
                    if (result.Items != null)
                    {
                        if (result.Items.Count > 0)
                        {
                            model.Item = result.Items[0];
                        }
                    }
                }
            }

            // *** Set return url ***
            if (TempData.ContainsKey(ReturnUrl))
            {
                model.ReturnUrl     = TempData[ReturnUrl].ToString();
                TempData[ReturnUrl] = TempData[ReturnUrl];
            }

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult AddEdit(NonVACareItemAddEdit model)
        {
            ActionResult returnResult;

            // *** Post data ***

            BrokerOperationResult result;

            // *** Check model state ***
            if (ModelState.IsValid)
            {
                result = this.DashboardRepository.NonVACare.SaveItem(model.Item);

                // *** Check result ***
                if (!result.Success)
                {
                    this.Error(result.Message);
                    returnResult = View("AddEdit", model);
                }
                else
                {
                    returnResult = RedirectToAction("Index", new { @page = "1", @dfn = model.CurrentPatientDfn, @pien = model.CurrentPregnancyIen, @itemType = model.CurrentItemType });
                }
            }
            else
            {
                returnResult = View("AddEdit", model);
            }

            // *** Set return url ***
            if (TempData.ContainsKey(ReturnUrl))
            {
                model.ReturnUrl     = TempData[ReturnUrl].ToString();
                TempData[ReturnUrl] = TempData[ReturnUrl];
            }

            return(returnResult);
        }