Example #1
0
        /// <summary>
        /// Deletes the bu commitment request.
        /// </summary>
        /// <param name="refId">The reference identifier.</param>
        /// <returns>OpeningCommitmentResponse.</returns>
        public OpeningCommitmentResponse DeleteOpeningCommitment(string refId)
        {
            var openingCommitmentResponse = new OpeningCommitmentResponse {
                Acknowledge = AcknowledgeType.Success
            };

            using (var scope = new TransactionScope())
            {
                var openingCommitmentForDelete = OpeningCommitmentDao.GetOpeningCommitmentbyRefId(refId);


                openingCommitmentResponse.Message = OpeningCommitmentDao.DeleteOpeningCommitment(openingCommitmentForDelete);
                if (openingCommitmentResponse.Message != null)
                {
                    openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                    scope.Dispose();
                    return(openingCommitmentResponse);
                }
                scope.Complete();
            }

            return(openingCommitmentResponse);
        }
Example #2
0
        /// <summary>
        /// Inserts the bu commitment request.
        /// </summary>
        /// <param name="openingCommitment">The b u commitment request.</param>
        /// <returns>OpeningCommitmentResponse.</returns>
        public OpeningCommitmentResponse InsertOpeningCommitment(OpeningCommitmentEntity openingCommitment)
        {
            var openingCommitmentResponse = new OpeningCommitmentResponse {
                Acknowledge = AcknowledgeType.Success
            };


            if (openingCommitment != null && !openingCommitment.Validate())
            {
                foreach (var error in openingCommitment.ValidationErrors)
                {
                    openingCommitmentResponse.Message += error + Environment.NewLine;
                }
                openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                return(openingCommitmentResponse);
            }

            using (var scope = new TransactionScope())
            {
                if (openingCommitment != null)
                {
                    var validOpeningCommitment = OpeningCommitmentDao.GetOpeningCommitmentbyRefNo(openingCommitment.RefNo);
                    if (validOpeningCommitment != null)
                    {
                        openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                        openingCommitmentResponse.Message     = "Số cam kết chi " + openingCommitment.RefNo + " đã tồn tại !";
                        return(openingCommitmentResponse);
                    }

                    if (!string.IsNullOrEmpty(openingCommitmentResponse.Message))
                    {
                        openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                        return(openingCommitmentResponse);
                    }

                    openingCommitment.RefId           = Guid.NewGuid().ToString();
                    openingCommitmentResponse.Message = OpeningCommitmentDao.InsertOpeningCommitment(openingCommitment);

                    if (!string.IsNullOrEmpty(openingCommitmentResponse.Message))
                    {
                        openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                        return(openingCommitmentResponse);
                    }

                    foreach (var openingCommitmentDetail in openingCommitment.OpeningCommitmentDetails)
                    {
                        openingCommitmentDetail.RefId       = openingCommitment.RefId;
                        openingCommitmentDetail.RefDetailId = Guid.NewGuid().ToString();
                        if (!openingCommitmentDetail.Validate())
                        {
                            foreach (var error in openingCommitmentDetail.ValidationErrors)
                            {
                                openingCommitmentResponse.Message += error + Environment.NewLine;
                            }
                            openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                            return(openingCommitmentResponse);
                        }
                        openingCommitmentResponse.Message =
                            OpeningCommitmentDetailDao.InsertOpeningCommitmentDetail(openingCommitmentDetail);
                        if (!string.IsNullOrEmpty(openingCommitmentResponse.Message))
                        {
                            openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                            return(openingCommitmentResponse);
                        }
                    }

                    if (openingCommitmentResponse.Message != null)
                    {
                        openingCommitmentResponse.Acknowledge = AcknowledgeType.Failure;
                        scope.Dispose();
                        return(openingCommitmentResponse);
                    }
                    openingCommitmentResponse.RefId = openingCommitment.RefId;
                    scope.Complete();
                }

                return(openingCommitmentResponse);
            }
        }