Пример #1
0
        public ActionResult FetchPatronDataUsingLcnOrPnr(int orderItemNodeId, string lcn, string pnr, bool cache = true)
        {
            var json = new ResultResponse();

            try
            {
                var content = _orderItemManager.GetOrderItem(orderItemNodeId);
                var eventId = _orderItemManager.GenerateEventId(EVENT_TYPE);

                SierraModel sm = null;
                if (cache)
                {
                    sm = _patronDataProviderSierraCache.GetPatronInfoFromLibraryCardNumberOrPersonnummer(lcn, pnr);
                }
                else
                {
                    sm = _patronDataProviderSierra.GetPatronInfoFromLibraryCardNumberOrPersonnummer(lcn, pnr);
                }

                if (!String.IsNullOrEmpty(sm.id))
                {
                    _orderItemManager.SetPatronData(content.NodeId, JsonConvert.SerializeObject(sm), sm.record_id, sm.ptype, sm.home_library, sm.aff);
                    _orderItemManager.SaveWithoutEventsAndWithSynchronousReindexing(content.NodeId, false, false);
                }
                _orderItemManager.AddSierraDataToLog(orderItemNodeId, sm, eventId);

                json.Success = true;
                json.Message = "Succcessfully loaded Sierra data from \"personnummer\" or library card number.";
            }
            catch (Exception e)
            {
                json.Success = false;
                json.Message = "Failed to load Sierra data from \"personnummer\" or library card number: " + e.Message;
            }

            return(Json(json, JsonRequestBehavior.AllowGet));
        }