예제 #1
0
        /// <summary>
        /// Add Learning Story
        /// </summary>
        public int AddItem(LearningStory learningStory, LearningStoryItem item, HeaderInfo _headerInfo)
        {
            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                int nextItemUID = CommonDB.GetLastUID("learningstoryitem") + 1;

                var commandString =
                    (

                        " INSERT INTO learningstoryitem " +
                        " (UID, " +
                        " FKLearningStoryUID, " +
                        " FKCodeType, " +
                        " FKCodeValue " +
                        " )" +
                        " VALUES " +
                        "( " +
                        "  @UID " +
                        " ,@FKLearningStoryUID " +
                        " ,@FKCodeType " +
                        " ,@FKCodeValue " +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    command.Parameters.AddWithValue("@UID", nextItemUID);
                    command.Parameters.AddWithValue("@FKLearningStoryUID", learningStory.UID);
                    command.Parameters.AddWithValue("@FKCodeType", item.FKCodeType);
                    command.Parameters.AddWithValue("@FKCodeValue", item.FKCodeValue);

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        var respError = new LearningStory.LearningStoryAddResponse();
                        respError.responseStatus            = new ResponseStatus();
                        respError.responseStatus.ReturnCode = -0025;
                        respError.responseStatus.ReasonCode = 0002;
                        respError.responseStatus.Message    = "Error adding Learning Story Item. " + ex;
                    }
                }
            }

            return(UID);
        }
예제 #2
0
        /// <summary>
        /// Add Learning Story
        /// </summary>
        public LearningStoryAddResponse Add(LearningStoryAddRequest learningStoryAddRequest)
        {
            var response = new LearningStoryAddResponse();

            response.responseStatus = new ResponseStatus();

            this.UserIdCreatedBy = learningStoryAddRequest.headerInfo.UserID;
            this.UserIdUpdatedBy = learningStoryAddRequest.headerInfo.UserID;

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                UID           = CommonDB.GetLastUID("LearningStory") + 1;
                RecordVersion = 1;

                var commandString =
                    (
                        "INSERT INTO LearningStory (" +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.UID +
                        " ,@" + FieldName.FKChildUID +
                        " ,@" + FieldName.FKEducatorUID +
                        " ,@" + FieldName.FKRoomCode +
                        " ,@" + FieldName.Date +
                        " ,@" + FieldName.Story +
                        " ,@" + FieldName.AnalysisOfLearning +
                        " ,@" + FieldName.ExtensionOfLearning +
                        " ,@" + FieldName.ParentsComments +

                        ", @" + FieldName.UpdateDateTime +
                        ", @" + FieldName.UserIdUpdatedBy +
                        ", @" + FieldName.CreationDateTime +
                        ", @" + FieldName.UserIdCreatedBy +
                        ", @" + FieldName.RecordVersion +
                        ", @" + FieldName.IsVoid +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    IsVoid = "N";
                    AddSqlParameters(command);

                    command.Parameters.Add("@" + FieldName.CreationDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                    command.Parameters.Add("@" + FieldName.UserIdCreatedBy, MySqlDbType.VarChar).Value   = this.UserIdCreatedBy;
                    //command.Parameters.Add("@" + FieldName.IsVoid, MySqlDbType.VarChar).Value = "N";

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        var respError = new LearningStoryAddResponse();
                        respError.responseStatus            = new ResponseStatus();
                        respError.responseStatus.ReturnCode = -0025;
                        respError.responseStatus.ReasonCode = 0001;
                        respError.responseStatus.Message    = "Error adding Learning Story. " + ex;
                    }
                }
            }

            // Add items


            if (LearningOutcomes != null)
            {
                foreach (var learningOutcome in LearningOutcomes)
                {
                    if (learningOutcome.Action == "TBD")
                    {
                        continue;
                    }
                    var lit = new LearningStoryItem().AddItem(this, learningOutcome, _headerInfo);
                }
            }

            if (Practices != null)
            {
                foreach (var practice in Practices)
                {
                    if (practice.Action == "TBD")
                    {
                        continue;
                    }
                    var lit = new LearningStoryItem().AddItem(this, practice, _headerInfo);
                }
            }
            if (Principles != null)
            {
                foreach (var principle in Principles)
                {
                    if (principle.Action == "TBD")
                    {
                        continue;
                    }
                    var lit = new LearningStoryItem().AddItem(this, principle, _headerInfo);
                }
            }
            return(response);
        }
예제 #3
0
        /// <summary>
        /// Add Learning Story
        /// </summary>
        public ChildRoomAddResponse Add(ChildRoomAddRequest childRoomAddRequest)
        {
            this.UserIdCreatedBy = childRoomAddRequest.headerInfo.UserID;
            this.UserIdUpdatedBy = childRoomAddRequest.headerInfo.UserID;

            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                UID           = CommonDB.GetLastUID("ChildRoom") + 1;
                RecordVersion = 1;

                var commandString =
                    (
                        "INSERT INTO LearningStory (" +
                        FieldString() +
                        ")" +
                        " VALUES " +
                        "( " +
                        "  @" + FieldName.UID +
                        " ,@" + FieldName.FKChildUID +
                        " ,@" + FieldName.FKRoomUID +
                        " ,@" + FieldName.StartDate +
                        " ,@" + FieldName.EndDate +

                        ", @" + CommonDB.FieldName.UpdateDateTime +
                        ", @" + CommonDB.FieldName.UserIdUpdatedBy +
                        ", @" + CommonDB.FieldName.CreationDateTime +
                        ", @" + CommonDB.FieldName.UserIdCreatedBy +
                        ", @" + CommonDB.FieldName.RecordVersion +
                        ", @" + CommonDB.FieldName.IsVoid +
                        " )"
                    );

                using (var command = new MySqlCommand(
                           commandString, connection))
                {
                    AddSqlParameters(command);

                    command.Parameters.Add("@" + LearningStory.FieldName.CreationDateTime, MySqlDbType.DateTime).Value = DateTime.Now;
                    command.Parameters.Add("@" + LearningStory.FieldName.UserIdCreatedBy, MySqlDbType.VarChar).Value   = this.UserIdCreatedBy;
                    command.Parameters.Add("@" + LearningStory.FieldName.IsVoid, MySqlDbType.VarChar).Value            = "N";

                    try
                    {
                        connection.Open();
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LogFile.WriteToTodaysLogFile(ex.ToString(), _headerInfo.UserID);

                        return(new ChildRoomAddResponse
                        {
                            responseStatus =
                            {
                                ReturnCode = -0025,
                                ReasonCode =  0001,
                                Message    = "Error adding Learning Story. " + ex
                            }
                        });
                    }

                    return(new ChildRoomAddResponse
                    {
                        responseStatus = { ReturnCode = 0001, ReasonCode = 0001 }
                    });
                }
            }
        }