public IHttpActionResult PutAssessment(AssessmentDTO assessmentDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            //var assessment = AssessmentRepo.Get(id);
            if (assessmentDTO == null)
            {
                return(BadRequest("Missing values."));
            }

            //if (assessmentName != null)
            //{
            //    assessment.AssessmentName = assessmentName;
            //}
            //if (summary != null)
            //    assessment.Summary = summary;

            //if (maxGrade >0)
            //    assessment.MaxGrade = maxGrade;

            Assessment assessment = Mapper.Map <Assessment>(assessmentDTO);



            AssessmentRepo.Update(assessment);
            AssessmentRepo.Save();


            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PostAssessment(AssessmentDTO assessmentDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            //if (assessmentName == null || summary == null || maxGrade <= 0 || moduleID <= 0)
            //    return BadRequest("One or more parameters are missing values");



            //Assessment assessment = new Assessment { AssessmentName = assessmentName, Summary = summary, MaxGrade = maxGrade, ModuleID = moduleID };

            Assessment assessment = Mapper.Map <Assessment>(assessmentDTO);

            AssessmentRepo.Add(assessment);
            try
            {
                AssessmentRepo.Save();
                return(Ok(assessment));
            }
            catch
            {
                return(BadRequest("Failed to add assessment"));
            }
        }
Exemplo n.º 3
0
        public void ParseAssessmentWithCorrectIdProperty_Test()
        {
            // Arrange
            AssessmentDTO assessmentDTO = new AssessmentDTO()
            {
                Id                         = 3,
                Name                       = "Test name",
                Description                = "Test Description",
                URL                        = "Test URL",
                AssessmentTypeId           = 1,
                ScopeProjectConstraintId   = 1,
                TimeProjectConstraintId    = 1,
                QualityProjectConstraintId = 1,
                UnitId                     = 1,
                ExpertTime                 = 10m,
                Comment                    = "Test Comment",
                FinishDate                 = DateTime.MaxValue,
                StartDate                  = DateTime.MinValue,
                Project                    = "Test Project",
                Unit                       = "Test unit",
                Version                    = "Test version",
                Improvements               = 3,
                CoordinatorTime            = 10m,
                CostProjectConstraintId    = 1
            };

            // Act
            Assessment assessment = factory.Parse(assessmentDTO);

            // Assert
            Assert.True(assessment.Id > 0);
        }
Exemplo n.º 4
0
 public Assessment Parse(AssessmentDTO assessmentDTO)
 {
     if (assessmentDTO.Id != 0)
     {
         return(ParseForEdit(assessmentDTO));
     }
     else
     {
         return(ParseForAdd(assessmentDTO));
     }
 }
Exemplo n.º 5
0
        public void ParseAssessmentParameterNull_Test()
        {
            // Arrange
            AssessmentDTO assessmentDTO = null;

            // Act

            Assessment assessment = factory.Parse(assessmentDTO);

            // Assert
        }
Exemplo n.º 6
0
        public HttpResponseMessage EditAssessment([FromBody] AssessmentDTO assessmentDTO)
        {
            var assessment = DTOFactory.Parse(assessmentDTO);

            UnitOfWork.AssessmentRepository.Update(assessment);

            var _context = GlobalHost.ConnectionManager.GetHubContext <AssessmentHub>();

            _context.Clients.All.onUpdate();

            return(Request.CreateResponse(HttpStatusCode.OK, DTOFactory.Create(assessment)));
        }
        public async Task <IHttpActionResult> GetAssessment(int id)
        {
            AssessmentDTO dto = await AssessmentService.SearchSingleAssessmentByIdAsync(id);

            if (dto != null)
            {
                return(Ok(dto));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 8
0
        public HttpResponseMessage PostAssessment([FromBody] AssessmentDTO assessment)
        {
            var entity = DTOFactory.Parse(assessment);

            if (entity == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Could not parse new Assessment"));
            }

            UnitOfWork.AssessmentRepository.Insert(entity);

            return(Request.CreateResponse(HttpStatusCode.Created, DTOFactory.Create(entity)));
        }
Exemplo n.º 9
0
        public IHttpActionResult GetAssessment(int id)
        {
            Assessment Assessment = (Assessment)assessmentRepo.Find(id);

            if (Assessment == null)
            {
                return(NotFound());
            }

            Mapper.Initialize(c => c.CreateMap <Assessment, AssessmentDTO>());

            AssessmentDTO AssessmentDTO = Mapper.Map <AssessmentDTO>(Assessment);

            return(Ok(AssessmentDTO));
        }
        public IHttpActionResult GetAssessment(int id)
        {
            Assessment Assessment = AssessmentRepo.Get(id);

            if (Assessment == null)
            {
                return(NotFound());
            }



            AssessmentDTO AssessmentDTO = Mapper.Map <AssessmentDTO>(Assessment);

            return(Ok(AssessmentDTO));
        }
Exemplo n.º 11
0
        public IHttpActionResult PostAssessment(AssessmentDTO AssessmentDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Mapper.Initialize(c => c.CreateMap <AssessmentDTO, Assessment>());

            Assessment Assessment = Mapper.Map <Assessment>(AssessmentDTO);

            assessmentRepo.Add(Assessment);
            assessmentRepo.Save();

            return(CreatedAtRoute("DefaultApi", new { id = Assessment.ID }, Assessment));
        }
        public async Task <IHttpActionResult> UpdateAssessment([FromBody] AssessmentDTO assessmentModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var updatedAssessment = await AssessmentService.UpdateAssessmentAsync(assessmentModel);

            if (updatedAssessment != null)
            {
                return(Ok(updatedAssessment));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 13
0
        //Update Assessment (async)
        public async Task <AssessmentDTO> UpdateAssessmentAsync(AssessmentDTO modelDTO)
        {
            try
            {
                using (var unitOfWork = unitOfWorkFactory.Create())
                {
                    if (!string.IsNullOrEmpty(modelDTO._ImageFileUrl))
                    {
                        var tempImageTypeModel = unitOfWork.ImageFileTypeRepository.GetSingleOrDefaultImageFileType(x => x.Type.Contains("AssessmentFile"));

                        ImageFileTypeDTO imageFileTypeDTO = _Mapper_ToDTO.Map <ImageFileTypeModel, ImageFileTypeDTO>(tempImageTypeModel);

                        modelDTO.ImageFileUrl = new ImageFileUrlDTO()
                        {
                            Url             = modelDTO._ImageFileUrl,
                            CreateDate      = DateTime.Now,
                            ImageFileTypeId = imageFileTypeDTO.ImageFileTypeId
                        };
                    }
                    else
                    {
                        modelDTO.ImageFileUrl = null;
                    }

                    AssessmentModel model = _Mapper_ToModel.Map <AssessmentDTO, AssessmentModel>(modelDTO);

                    bool result = unitOfWork.AssessmentRepository.Update(model);

                    AssessmentDTO modelRTN = null;
                    if (result)
                    {
                        await unitOfWork.SaveChangesAsync();

                        modelRTN = _Mapper_ToDTO.Map <AssessmentModel, AssessmentDTO>(model);
                    }

                    return(modelRTN);
                }
            }
            catch (Exception ex)
            {
                LogException(ex);
                throw ex;
            }
        }
        public async Task <IHttpActionResult> AddAssessment([FromBody] AssessmentDTO assessmentModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newAssessmentId = await AssessmentService.AddAssessmentAsync(assessmentModel);

            if (newAssessmentId != 0)
            {
                return(Ok(newAssessmentId));
            }
            else
            {
                return(NotFound());
            }
        }
Exemplo n.º 15
0
        public void CreateAssessmentDTOWhichIsHasToBeNotNull_Test()
        {
            // Arrange
            IList <User> experts = new List <User>();

            for (int i = 0; i < 5; i++)
            {
                experts.Add(FactoryForTest.GetUser(id: i + 1, isCompetenceManager: true, isCoordinator: true));
            }

            var assessment = FactoryForTest.GetAssessment(experts: experts);

            // Act
            AssessmentDTO assessmentDTO = factory.Create(assessment);

            // Assert
            Assert.IsNotNull(assessmentDTO);
        }
Exemplo n.º 16
0
        public AssessmentDTO GetAssessmentsDTO(int studentId)
        {
            AssessmentDTO assessment = (from p in svmContext.tblassessment
                                        join q in svmContext.tblstudent
                                        on p.StudentId equals q.StudentId
                                        //join r in svmContext.tbltuition
                                        // on p.EducationalLevel equals r.DimEnrollmentId
                                        //  join s in svmContext.tblmisc
                                        //on p.EducationalLevel equals s.DimMiscId
                                        where p.StudentId == studentId

                                        select new AssessmentDTO
            {
                FirstName = q.FirstName,
                MiddleName = q.MiddleName,
                LastName = q.LastName,
                path = q.path,
                StudentNo = q.StudentNo
            }).FirstOrDefault();

            return(assessment);
        }
Exemplo n.º 17
0
        public IHttpActionResult PutAssessment(int id, AssessmentDTO AssessmentDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != AssessmentDTO.ID)
            {
                return(BadRequest());
            }

            Mapper.Initialize(c => c.CreateMap <AssessmentDTO, Assessment>());

            Assessment Assessment = Mapper.Map <Assessment>(AssessmentDTO);

            assessmentRepo.Update(Assessment);

            try
            {
                assessmentRepo.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AssessmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 18
0
        private Assessment ParseForAdd(AssessmentDTO assessmentDTO)
        {
            Assessment assessment = new Assessment()
            {
                AssessmentTypeId = assessmentDTO.AssessmentTypeId,
                Comment          = assessmentDTO.Comment,
                Description      = assessmentDTO.Description,
                FinishDate       = assessmentDTO.FinishDate,
                Id                  = assessmentDTO.Id,
                Name                = assessmentDTO.Name,
                Project             = assessmentDTO.Project,
                ProjectId           = assessmentDTO.ProjectId,
                StartDate           = assessmentDTO.StartDate,
                Unit                = assessmentDTO.Unit,
                UnitId              = assessmentDTO.UnitId,
                URL                 = assessmentDTO.URL,
                Version             = assessmentDTO.Version,
                Recommendations     = assessmentDTO.Recommendations,
                Improvements        = assessmentDTO.Improvements,
                CoordinatorTime     = assessmentDTO.CoordinatorTime,
                ExpertTime          = assessmentDTO.ExpertTime,
                ServiceQualityScore = assessmentDTO.ServiceQualityScore,
            };

            assessment.ScopeProjectConstraintId   = defaultConstraintId;
            assessment.TimeProjectConstraintId    = defaultConstraintId;
            assessment.QualityProjectConstraintId = defaultConstraintId;
            assessment.CostProjectConstraintId    = defaultConstraintId;

            assessment.Coordinator    = LoadUserData(assessmentDTO.Coordinator);
            assessment.TechLead       = LoadUserData(assessmentDTO.TechLead);
            assessment.ProjectManager = LoadUserData(assessmentDTO.ProjectManager);
            LoadSampleDataToAssessment(assessment);

            return(assessment);
        }
Exemplo n.º 19
0
        private void FrmPaymentMaintenance_Load(object sender, EventArgs e)
        {
            cbTransferee.Enabled = false;
            //eager load discounts
            lstDiscount = _assessmentService.GetDiscount();

            var lstScholarshipRegular    = lstDiscount.Where(x => x.DiscountTypeId == 6).ToList();
            var lstScholarshipTransferee = lstDiscount.Where(x => x.DiscountTypeId == 5).ToList();
            var lstEarlyBird             = lstDiscount.Where(x => x.DiscountTypeId == 3).ToList();


            //siblingDiscountType = lstSibling[0].DiscountTypeId;
            //referralDiscountType = lstReferral[0].DiscountTypeId;



            // combobox mode of payment
            PaymentsDTO payments = _paymentService.GetPaymentById(Global.selectedId);

            cmbModeOfPayment.DataSource    = _paymentService.GetModeOfPayment();
            cmbModeOfPayment.ValueMember   = "ModeOfPaymentId";
            cmbModeOfPayment.DisplayMember = "ModeOfPaymentDesc";
            cmbModeOfPayment.SelectedIndex = 0;

            lblTransactionDate.Text = DateTime.Now.ToShortDateString();
            //combobox payment term (first/second/third/fourth grading)


            //load the payments grid

            List <PaymentsDTO> lstPayments   = _paymentService.GetPaymentsByStudentId(Global.selectedStudent);
            AssessmentDTO      assessmentDTO = _assessmentService.GetAssessmentsDTO(Global.selectedStudent);
            var studPaymentBindingList       = new BindingList <PaymentsDTO>(lstPayments);
            var studPaymentBindingSource     = new BindingSource(studPaymentBindingList, null);

            //###################      singit the textboxex    ######################
            var lstAssessment = _assessmentService.GetAssessment(Global.selectedStudent);

            txtMiscAmountDue.Text    = lstAssessment.DeferredMisc.ToString();
            txtTuitionAmountDue.Text = lstAssessment.PaymentPerDue.ToString();
            txtTotalAmount.Text      = (Convert.ToDouble(txtMiscAmountDue.Text) + Convert.ToDouble(txtMiscAmountDue.Text)).ToString("#.##");

            //determine due dates
            lstDueDates = _dueDatesService.GetDueDates(lstAssessment.PaymentTerm);

            //get high and low for dates
            dateLow = lstDueDates.Where(x => x.DueDate <= DateTime.Now).
                      OrderBy(x => x.DueDate).LastOrDefault().DueDate;

            dateHigh = lstDueDates.Where(x => x.DueDate >= DateTime.Now).
                       OrderBy(x => x.DueDate).LastOrDefault().DueDate;

            if (lstPayments.Count >= 1)
            {
                // cbTransferee.Checked = assessmentDTO.isTransferree;
                //this is not downpayment
            }
            else //if no payment given yet,
            {
                cbDownpayment.Checked = true;

                penalizedFee = DateTime.Now > lstDueDates[0].DueDate ? Convert.ToDouble(txtTuitionAmountDue.Text) +
                               ((Convert.ToDouble(txtTuitionAmountDue.Text) / 100) * 3.5) : 0;

                txtPenalty.Text      = ((Convert.ToDouble(txtTuitionAmountDue.Text) / 100) * 3.5).ToString("#.##");
                cbTransferee.Checked = false;
            }

            //payment term annual or downpayment  and not late for anything (no penalty)
            if ((lstAssessment.PaymentTerm == 1 || cbDownpayment.Checked == true) && penalizedFee == 0)
            {
                //early bird discount
                TuitionDTO earlyBirdVal = lstDiscount.Where(x => x.DiscountTypeId == 3 &&
                                                            Convert.ToDateTime(x.DiscountParam) >= DateTime.Now).
                                          OrderBy(x => x.DiscountVal).LastOrDefault();

                txtEarlyBird.Text = (Convert.ToDouble(earlyBirdVal.DiscountVal) *
                                     (lstAssessment.OriginalAmount) / 100).ToString("#.##");

                lblEarlyBird.Visible = true;
                lblEarlyBird.Text    = "Early Bird for " + Convert.ToDateTime(earlyBirdVal.DiscountParam).ToShortDateString()
                                       + " ," + (earlyBirdVal.DiscountVal) + "%";


                txtTotalAmount.Text = (Convert.ToDouble(txtPenalty.Text) + Convert.ToDouble(txtTotalAmount.Text)
                                       - Convert.ToDouble(txtEarlyBird.Text)).ToString("#.##");
            }
            else
            {
                lblEarlyBird.Visible = false;
                txtTotalAmount.Text  = (Convert.ToDouble(txtPenalty.Text) + Convert.ToDouble(txtTotalAmount.Text) + Convert.ToDouble(txtMiscAmountDue.Text)).ToString("#.##");
            }
            //txtTotalAmountBal.Text = (lstAssessment.FullAmount - (Convert.ToDouble(txtAmount.Text))).ToString("#.##");


            txtTotalRemainingBal.Text = (lstAssessment.FullAmount).ToString("#.##");
            PaymentsDTO lastPayment = lstPayments.LastOrDefault();

            //txtRemainingMiscBal.Text =Convert.ToDouble(txtMiscAmountDue.Text) - lastPayment.
            //####################/till here                    #######################



            pbStudent.Image = Image.FromFile(lstAssessment.path);

            dgvStudentPayments.AutoGenerateColumns = false;

            dgvStudentPayments.ColumnCount = 6;

            dgvStudentPayments.Columns[0].Name             = "colAmount";
            dgvStudentPayments.Columns[0].HeaderText       = "Amount";
            dgvStudentPayments.Columns[0].DataPropertyName = "Amount";

            //dgvStudentPayments.Columns[1].Name = "colBank";
            //dgvStudentPayments.Columns[1].HeaderText = "Bank";
            //dgvStudentPayments.Columns[1].DataPropertyName = "BankName";

            dgvStudentPayments.Columns[1].Name             = "colModeOfPayment";
            dgvStudentPayments.Columns[1].HeaderText       = "Mode Of Payment";
            dgvStudentPayments.Columns[1].DataPropertyName = "ModeOfPayment";

            dgvStudentPayments.Columns[2].Name             = "colTransactionDate";
            dgvStudentPayments.Columns[2].HeaderText       = "Transaction Date";
            dgvStudentPayments.Columns[2].DataPropertyName = "TransactionDate";

            dgvStudentPayments.Columns[3].Name             = "colRemaniningBalance";
            dgvStudentPayments.Columns[3].HeaderText       = "Remaining Balance";
            dgvStudentPayments.Columns[3].DataPropertyName = "Balance";

            dgvStudentPayments.Columns[4].Name             = "colOriginalBalance";
            dgvStudentPayments.Columns[4].HeaderText       = "Original Balance";
            dgvStudentPayments.Columns[4].DataPropertyName = "OriginalBalance";

            dgvStudentPayments.DataSource = studPaymentBindingSource;

            //fill the textboxes
            txtStudentName.Text = assessmentDTO.FirstName + " " + assessmentDTO.MiddleName.ToString() + " " + assessmentDTO.LastName.ToString();
            txtStudentNo.Text   = assessmentDTO.StudentNo;

            //txtBalance.Text = lstPayments[lstPayments.Count - 1].Balance.ToString();

            //load payment term

            //cmbPaymentTerm.DataSource = _paymentService.GetDateParameters();
            //cmbPaymentTerm.ValueMember = "DateParameterId";
            //cmbPaymentTerm.DisplayMember = "DatesDescription";
            //cmbPaymentTerm.SelectedIndex = -1;
        }
Exemplo n.º 20
0
 public AssessmentWorkflow(AssessmentDTO assessmentDTO)
 {
     this.assessmentDTO = assessmentDTO;
 }
Exemplo n.º 21
0
        private Assessment ParseForEdit(AssessmentDTO assessmentDTO)
        {
            Assessment assessment = unit.AssessmentRepository.Get(p => p.Id == assessmentDTO.Id).FirstOrDefault();

            if (assessment != null)
            {
                if (assessment.Comment != assessmentDTO.Comment)
                {
                    assessment.Comment = assessmentDTO.Comment;
                }

                if (assessment.Description != assessmentDTO.Description)
                {
                    assessment.Description = assessmentDTO.Description;
                }

                if (assessment.FinishDate != assessmentDTO.FinishDate)
                {
                    assessment.FinishDate = assessmentDTO.FinishDate;
                }

                if (assessment.Name != assessmentDTO.Name)
                {
                    assessment.Name = assessmentDTO.Name;
                }

                if (assessment.Project != assessmentDTO.Project)
                {
                    assessment.Project = assessmentDTO.Project;
                }

                if (assessment.ProjectId != assessmentDTO.ProjectId)
                {
                    assessment.ProjectId = assessmentDTO.ProjectId;
                }

                if (assessment.StartDate != assessmentDTO.StartDate)
                {
                    assessment.StartDate = assessmentDTO.StartDate;
                }

                if (assessment.Unit != assessmentDTO.Unit)
                {
                    assessment.Unit = assessmentDTO.Unit;
                }

                if (assessment.UnitId != assessmentDTO.UnitId)
                {
                    assessment.UnitId = assessmentDTO.UnitId;
                }

                if (assessment.URL != assessmentDTO.URL)
                {
                    assessment.URL = assessmentDTO.URL;
                }

                if (assessment.Version != assessmentDTO.Version)
                {
                    assessment.Version = assessmentDTO.Version;
                }

                if (assessment.Recommendations != assessmentDTO.Recommendations)
                {
                    assessment.Recommendations = assessmentDTO.Recommendations;
                }

                if (assessment.Improvements != assessmentDTO.Improvements)
                {
                    assessment.Improvements = assessmentDTO.Improvements;
                }

                if (assessment.CoordinatorTime != assessmentDTO.CoordinatorTime)
                {
                    assessment.CoordinatorTime = assessmentDTO.CoordinatorTime;
                }

                if (assessment.ExpertTime != assessmentDTO.ExpertTime)
                {
                    assessment.ExpertTime = assessmentDTO.ExpertTime;
                }

                if (assessment.ServiceQualityScore != assessmentDTO.ServiceQualityScore)
                {
                    assessment.ServiceQualityScore = assessmentDTO.ServiceQualityScore;
                }

                if (assessment.ScopeProjectConstraintId != assessmentDTO.ScopeProjectConstraintId)
                {
                    assessment.ScopeProjectConstraintId = assessmentDTO.ScopeProjectConstraintId;
                }

                if (assessment.TimeProjectConstraintId != assessmentDTO.TimeProjectConstraintId)
                {
                    assessment.TimeProjectConstraintId = assessmentDTO.TimeProjectConstraintId;
                }

                if (assessment.QualityProjectConstraintId != assessmentDTO.QualityProjectConstraintId)
                {
                    assessment.QualityProjectConstraintId = assessmentDTO.QualityProjectConstraintId;
                }

                if (assessment.CostProjectConstraintId != assessmentDTO.CostProjectConstraintId)
                {
                    assessment.CostProjectConstraintId = assessmentDTO.CostProjectConstraintId;
                }


                if (assessment.ProjectManager.Name != assessmentDTO.ProjectManager)
                {
                    assessment.ProjectManager = LoadUserData(assessmentDTO.ProjectManager);
                }

                if (assessment.Coordinator.Name != assessmentDTO.Coordinator)
                {
                    assessment.Coordinator = LoadUserData(assessmentDTO.Coordinator);
                }

                if (assessment.TechLead.Name != assessmentDTO.TechLead)
                {
                    assessment.TechLead = LoadUserData(assessmentDTO.TechLead);
                }

                if (assessment.AssessmentTypeId != assessmentDTO.AssessmentTypeId)
                {
                    assessment.AssessmentTypeId = assessmentDTO.AssessmentTypeId;
                    assessment.Areas            = new HashSet <Area>();
                    LoadSampleDataToAssessment(assessment);
                }

                return(assessment);
            }
            else
            {
                return(null);
            }
        }