private static void UpdateEventStatus(Event eventInfo, string externalId) { EventStatus newStatus; switch (eventInfo.Status) { case EventStatus.ToSend: case EventStatus.Sent: newStatus = EventStatus.Sent; break; case EventStatus.Fill: newStatus = EventStatus.Complete; break; case EventStatus.InActive: default: newStatus = eventInfo.Status; break; } //update the event to the new status //currently we have to update the Event object as well as create a history entry for it eventInfo.Status = newStatus; using (var service = new EventHistoryService()) { EventHistory eh = new EventHistory(); eh.Date = DateTime.Now; eh.Status = newStatus; eh.Event = eventInfo; eh.ExternalId = externalId; service.Create(eh); } }
//prescription needs to be filled public static string FillPrescription(Event e) { e.Status = EventStatus.Fill; EventHistory eh = new EventHistory(); eh.Event = e; eh.Date = DateTime.Now; eh.Status = EventStatus.Fill; using (var eventService = new EventService()) using (var service = new EventHistoryService()) { try { eventService.Update(e); service.Create(eh); //this should be persisted in the database return("Your prescription is on the way! We will contact you when it is ready to be picked up."); } catch (Exception exception) { //this should be persisted in the database return("We're sorry, an application error has occurred; please contact your pharmacy to process your request."); } } }