public HandlerResponse executeActionAndGetResponse(string actionName, Dictionary <string, string> parameters) { if (actionName.Equals(NEW_WORKSHOP)) { string nextWorkshopID = workshopManager.getNextWorkshopID(); StringBuilder newWorkshopContents = workshopManager.createNewFileFromTemplate( nextWorkshopID, workshopManager.getWorkshopDir(), workshopManager.getWorkshopTemplate()); workshopManager.addWorkshop(newWorkshopContents); parameters.Add("id", nextWorkshopID); return(executeActionAndGetResponse(ALL_WORKSHOPS, parameters)); } else if (actionName.Equals(ALL_WORKSHOPS)) { XMLBuilder allWorkshopsXml = new XMLBuilder("workshop"); WorkshopRepository repository = workshopManager.getWorkshopRepository(); foreach (var workshop in repository) { allWorkshopsXml.addAttribute("name", workshop.getName()); allWorkshopsXml.addAttribute("status", workshop.getStatus()); allWorkshopsXml.addAttribute("duration", workshop.getDurationAsString()); } string formattedXml = getFormattedData(allWorkshopsXml.ToString()); return(new HandlerResponse(new StringBuilder(formattedXml), ALL_WORKSHOPS_STYLESHEET)); } //more else if()... return(null); }
public WorkshopManager() { Repository = new WorkshopRepository(); }