Ejemplo n.º 1
0
        public Message GetEntityById(WebOperationContext ctx, string entityName, string entityKPID)
        {
            Message responseMsg = null;

            try
            {
                // get the specified entities for the specified teams
                switch (entityName)
                {
                case "KPAccomplishmentMisses":
                    Accomplishment accomplishments = this.GetEntityById <Accomplishment>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <Accomplishment>(ctx, accomplishments, this.timer);
                    break;

                case "KPAuditItems":
                    AuditItem auditItems = this.GetEntityById <AuditItem>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <AuditItem>(ctx, auditItems, this.timer);
                    break;

                case "KPEffortInstances":
                    EffortInstance effortInstances = this.GetEntityById <EffortInstance>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <EffortInstance>(ctx, effortInstances, this.timer);
                    break;

                case "KPGoals":
                    Goal goals = this.GetEntityById <Goal>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <Goal>(ctx, goals, this.timer);
                    break;

                case "KPKeyInsightsInnovations":
                    KeyInsightInnovation keyInsightsInnovations = this.GetEntityById <KeyInsightInnovation>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <KeyInsightInnovation>(ctx, keyInsightsInnovations, this.timer);
                    break;

                case "KPMilestones":
                    Milestone milestones = this.GetEntityById <Milestone>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <Milestone>(ctx, milestones, this.timer);
                    break;

                case "KPProjects":
                    Project projects = this.GetEntityById <Project>(entityName, entityKPID);
                    responseMsg = HttpUtilities.GenerateResponse <Project>(ctx, projects, this.timer);
                    break;
                }
            }
            catch (Exception ex)
            {
                responseMsg = HttpUtilities.GenerateExceptionResponse(ctx, ex, "GET", HttpStatusCode.InternalServerError);
            }

            this.timer.Stop();
            return(responseMsg);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="entityName"></param>
        /// <param name="dataMsg"></param>
        /// <returns></returns>
        public Message SaveEntity(WebOperationContext ctx, string entityName, Message dataMsg)
        {
            Message responseMsg = null;
            string  jsonData    = JSON.GetPayload(dataMsg);
            string  errMsg      = string.Empty;

            try
            {
                switch (entityName)
                {
                case "KPAccomplishmentMisses":
                    Accomplishment accomplishment = this.SaveUserEntity <Accomplishment>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <Accomplishment>(ctx, accomplishment, this.timer);
                    break;

                //case "KPDocuments":
                //Goal goal = this.SaveUserEntity<Goal>(entityName, jsonData);
                //responseMsg = ctx.CreateJsonResponse<Goal>(goal);
                //    break;
                case "KPGoals":
                    Goal goal = this.SaveUserEntity <Goal>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <Goal>(ctx, goal, this.timer);
                    break;

                case "KPKeyInsightsInnovations":
                    KeyInsightInnovation keyInsights = this.SaveUserEntity <KeyInsightInnovation>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <KeyInsightInnovation>(ctx, keyInsights, this.timer);
                    break;

                case "KPMilestones":
                    Milestone milestone = this.SaveUserEntity <Milestone>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <Milestone>(ctx, milestone, this.timer);
                    break;

                case "KPProjects":
                    Project project = this.SaveUserEntity <Project>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <Project>(ctx, project, this.timer);
                    break;

                case "Views":
                    View view = this.SaveUserEntity <View>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <View>(ctx, view, this.timer);
                    break;

                case "Checkpoints":
                    Checkpoint checkpoint = this.SaveUserEntity <Checkpoint>(entityName, jsonData);
                    responseMsg = HttpUtilities.GenerateResponse <Checkpoint>(ctx, checkpoint, this.timer);
                    break;

                default:
                    errMsg      = string.Format("Error: No entity list found with the name: {0}", entityName);
                    responseMsg = HttpUtilities.GenerateExceptionResponse(ctx, new Exception(errMsg), "POST", HttpStatusCode.BadRequest);
                    break;
                }
            }
            catch (Exception ex)
            {
                responseMsg = HttpUtilities.GenerateExceptionResponse(ctx, ex, "POST", HttpStatusCode.InternalServerError);
            }

            this.timer.Stop();
            return(responseMsg);
        }