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)); }
public ActionResult SetProvider(int nodeId, string providerName, string providerOrderId, string providerInformation, string newFollowUpDate, bool updateStatusAndFollowUpDate = true) { var json = new ResultResponse(); try { var eventType = PROVIDER_DATA_UPDATED_EVENT_TYPE; if (updateStatusAndFollowUpDate) { eventType = EVENT_TYPE; } var eventId = _orderItemManager.GenerateEventId(eventType); if (updateStatusAndFollowUpDate) { _orderItemManager.SetFollowUpDate(nodeId, Convert.ToDateTime(newFollowUpDate), eventId, false, false); } _orderItemManager.SetProviderName(nodeId, providerName, eventId, false, false); _orderItemManager.SetProviderOrderId(nodeId, providerOrderId, eventId, false, false); _orderItemManager.SetProviderInformation(nodeId, providerInformation, eventId, false, false); if (updateStatusAndFollowUpDate) { _orderItemManager.SetStatus(nodeId, "03:Beställd", eventId, false, false); } _orderItemManager.SaveWithoutEventsAndWithSynchronousReindexing(nodeId); json.Success = true; json.Message = "Sparade data för beställning."; } catch (Exception e) { json.Success = false; json.Message = "Error: " + e.Message; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public ActionResult SendMail(OutgoingMailPackageModel m) { var json = new ResultResponse(); try { // Read current values that can be affected var orderItem = _orderItemManager.GetOrderItem(m.nodeId); var currentPatronEmail = orderItem.PatronEmail; var currentStatus = orderItem.Status; var eventId = _orderItemManager.GenerateEventId(EVENT_TYPE); // Send mail to recipient _mailService.SendMail(new OutgoingMailModel(orderItem.OrderId, m)); _orderItemManager.AddLogItem(m.nodeId, "MAIL_NOTE", "Skickat mail till " + m.recipientEmail, eventId, false, false); _orderItemManager.AddLogItem(m.nodeId, "MAIL", m.message, eventId, false, false); // Set PatronEmail property if it differs from recipientEmail if (currentPatronEmail != m.recipientEmail) { _orderItemManager.SetPatronEmail(m.nodeId, m.recipientEmail, eventId, false, false); } // Set FollowUpDate property if it differs from current DateTime currentFollowUpDate = orderItem.FollowUpDate; if (!String.IsNullOrEmpty(m.newFollowUpDate)) { DateTime parsedNewFollowUpDate = Convert.ToDateTime(m.newFollowUpDate); if (currentFollowUpDate != parsedNewFollowUpDate) { _orderItemManager.SetFollowUpDate(m.nodeId, parsedNewFollowUpDate, eventId, false, false); } } // Set status property if it differs from newStatus and if it is not -1 (no change) if (orderItem.StatusId != m.newStatusId && orderItem.StatusId != -1) { _orderItemManager.SetStatus(m.nodeId, m.newStatusId, eventId, false, false); } // Update cancellation reason if we have a value that is not -1 (no change) if (orderItem.CancellationReasonId != m.newCancellationReasonId && m.newCancellationReasonId != -1) { _orderItemManager.SetCancellationReason(m.nodeId, m.newCancellationReasonId, eventId, false, false); } // Update purchased material if we have a value that is not -1 (no change) if (orderItem.PurchasedMaterialId != m.newPurchasedMaterialId && m.newPurchasedMaterialId != -1) { _orderItemManager.SetPurchasedMaterial(m.nodeId, m.newPurchasedMaterialId, eventId, false, false); } _orderItemManager.SaveWithoutEventsAndWithSynchronousReindexing(m.nodeId); // Construct JSON response for client (ie jQuery/getJSON) json.Success = true; json.Message = "Sent mail and eventually changed some properties."; } catch (Exception e) { json.Success = false; json.Message = "Error: " + e.Message; } return(Json(json, JsonRequestBehavior.AllowGet)); }