Пример #1
0
        public void SaveAssessmentDocument(Guid documentId, int assessmentTypeId)
        {
            var objDoc = new AssessmentDocument();

            objDoc.AssessmentTypeId = assessmentTypeId;
            objDoc.DocumentId       = documentId;
            this.MomentaDb.AssessmentDocument.AddObject(objDoc);
            this.MomentaDb.SaveChanges();
        }
Пример #2
0
        public void SaveAssessmentDocument(Guid documentId, int assessmentTypeId)
        {
            var objDoc = new AssessmentDocument();

            objDoc.AssessmentTypeId = assessmentTypeId;
            objDoc.DocumentId = documentId;
            this.MomentaDb.AssessmentDocument.AddObject(objDoc);
            this.MomentaDb.SaveChanges();
        }
Пример #3
0
        public Assessment CreateAssessment(int associateId, int assessmentTypeId, DateTime assessmentDate, string pass, byte score, string Comment, string documentIds)
        {
            var assessment = new Assessment();
            assessment.AssociateId = associateId;
            assessment.AssessmentDate = assessmentDate;
            assessment.AssessmentTypeId = assessmentTypeId;
            assessment.Pass = pass;
            assessment.Score = score;
            assessment.Comment = Comment;
            this.MomentaDb.Assessment.AddObject(assessment);
            this.MomentaDb.SaveChanges();
            int assessmentId = assessment.AssessmentId;
            if (documentIds!="" && documentIds!=null)
            {
                var documentIdList = documentIds.Split(',');
                for (int documentIndex = 0; documentIndex < documentIdList.Count(); documentIndex++)
                {
                    var assessmentDocument = new AssessmentDocument();
                    assessmentDocument.AssessmentId = assessmentId;
                    assessmentDocument.AssessmentTypeId = assessmentTypeId;
                    assessmentDocument.DocumentId =new Guid(documentIdList[documentIndex]);

                    this.MomentaDb.AssessmentDocument.AddObject(assessmentDocument);
                    this.MomentaDb.SaveChanges();
                }

            }
            return assessment;
        }
Пример #4
0
        public void UpdateAssessment(Assessment assessment, string documentIds)
        {
            //this.MomentaDb.Assessment.ApplyCurrentValues(assessment);
            //this.MomentaDb.SaveChanges();
            var documentIdList = new List<string>();
            if (documentIds != "" && documentIds != null)
            {
                documentIdList = documentIds.Split(',').ToList();
            }
            var scsb =
              new SqlConnectionStringBuilder(
                  ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)
              {
                  Pooling = true,
                  AsynchronousProcessing = true
              };
            var command = new SqlCommand(@"Associate.UpdateAssessment")
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add("@AssessmentId", SqlDbType.Int);
            command.Parameters["@AssessmentId"].Value = assessment.AssessmentId;

            command.Parameters.Add("@AssociateId", SqlDbType.Int);
            command.Parameters["@AssociateId"].Value = assessment.AssociateId;

            command.Parameters.Add("@AssessmentTypeId", SqlDbType.Int);
            command.Parameters["@AssessmentTypeId"].Value = assessment.AssessmentTypeId;

            command.Parameters.Add("@AssessmentDate", SqlDbType.DateTime);
            command.Parameters["@AssessmentDate"].Value = assessment.AssessmentDate;

            command.Parameters.Add("@Score", SqlDbType.TinyInt);
            command.Parameters["@Score"].Value = assessment.Score;

            command.Parameters.Add("@Pass", SqlDbType.VarChar, 50);
            command.Parameters["@Pass"].Value = assessment.Pass;

            command.Parameters.Add("@Comment", SqlDbType.VarChar, 5000);
            command.Parameters["@Comment"].Value = Convert.ToString(assessment.Comment);

            string userName;
            string applicationName;
            Audit.GetUserAndApplicationName(out applicationName, out userName);

            command.Parameters.Add("@UserName", SqlDbType.Char, 64);
            command.Parameters["@UserName"].Value = userName;
            command.Parameters.Add("@ApplicationName", SqlDbType.Char, 64);
            command.Parameters["@ApplicationName"].Value = applicationName;
            command.Parameters.Add("@DocumentChange", SqlDbType.VarChar, 50);
            if (documentIdList.Count() > 0)
            {
                command.Parameters["@DocumentChange"].Value = "Uploaded "+documentIdList.Count()+" Documents";
            }
            else { command.Parameters["@DocumentChange"].Value = ""; }

            using (var conn = new SqlConnection(scsb.ConnectionString))
            {
                conn.Open();
                using (SqlTransaction trn = conn.BeginTransaction())
                {

                    command.Transaction = trn;
                    command.Connection = conn;
                    command.ExecuteNonQuery();

                    trn.Commit();
                }
            }

            if (documentIdList.Count() > 0)
            {

                for (int documentIndex = 0; documentIndex < documentIdList.Count(); documentIndex++)
                {
                    var assessmentDocument = new AssessmentDocument();
                    assessmentDocument.AssessmentId = assessment.AssessmentId;
                    assessmentDocument.AssessmentTypeId = assessment.AssessmentTypeId;
                    assessmentDocument.DocumentId = new Guid(documentIdList[documentIndex]);

                    this.MomentaDb.AssessmentDocument.AddObject(assessmentDocument);
                    this.MomentaDb.SaveChanges();
                }

            }
        }