Пример #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>
        /// Update child details
        /// </summary>
        /// <returns></returns>
        public WorkerUpdateResponse Update(WorkerUpdateRequest workerAddRequest)
        {
            WorkerUpdateResponse workerUpdateResponse = new WorkerUpdateResponse();

            workerUpdateResponse.XResponseStatus = new ResponseStatus();

            // Check record version. Do not allow update if version is different

            if (!CommonDB.IsTheSameRecordVersion(tablename: "Worker",
                                                 inputUID: UID,
                                                 recordVersion: RecordVersion,
                                                 responseStatus: workerUpdateResponse.XResponseStatus))
            {
                return(workerUpdateResponse);
            }

            string commandString = (
                "UPDATE Worker " +
                " SET  " +
                FieldName.UID + "= @" + FieldName.UID + ", " +
                FieldName.FirstName + "= @" + FieldName.FirstName + ", " +
                FieldName.Surname + "= @" + FieldName.Surname + ", " +
                FieldName.WLVL_Level + "= @" + FieldName.WLVL_Level + ", " +
                FieldName.UpdateDateTime + "= @" + FieldName.UpdateDateTime + ", " +
                FieldName.UserIdUpdatedBy + "= @" + FieldName.UserIdUpdatedBy + ", " +
                FieldName.RecordVersion + "= @" + FieldName.RecordVersion + ", " +
                FieldName.IsVoid + "= @" + FieldName.IsVoid +

                "    WHERE UID = @UID "
                );



            using (var connection = new MySqlConnection(ConnectionString.GetConnectionString()))
            {
                using (var command = new MySqlCommand(cmdText: commandString, connection: connection))
                {
                    RecordVersion++;
                    AddSqlParameters(command);

                    try
                    {
                        command.Parameters.AddWithValue("@" + FieldName.IsVoid, "N");

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

                        workerUpdateResponse.XResponseStatus.ReturnCode = -0020;
                        workerUpdateResponse.XResponseStatus.ReasonCode = 0001;
                        workerUpdateResponse.XResponseStatus.Message    = "Error saving client. " + ex;
                        return(workerUpdateResponse);
                    }
                }
            }

            return(workerUpdateResponse);
        }
Пример #3
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);
        }
Пример #4
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 }
                    });
                }
            }
        }