Пример #1
0
        public IActionResult LoadExamination()
        {
            List <EmployeeVM>         _trainees       = this.LoadAPI().Result;
            IEnumerable <Examination> examnations     = null;
            List <ExaminationVM>      loadExamination = new List <ExaminationVM>();

            //var token = HttpContext.Session.GetString("token");
            //client.DefaultRequestHeaders.Add("Authorization", token);
            var resTask = client.GetAsync("examinations");

            resTask.Wait();

            var result = resTask.Result;

            if (result.IsSuccessStatusCode)
            {
                var readTask = result.Content.ReadAsAsync <List <Examination> >();
                readTask.Wait();
                examnations = readTask.Result;

                foreach (var examination in examnations)
                {
                    foreach (var trainee in _trainees)
                    {
                        if (examination.EmployeeId == trainee.id)
                        {
                            ExaminationVM examinationDetail = new ExaminationVM();
                            examinationDetail.Id             = examination.Id;
                            examinationDetail.isDelete       = examination.isDelete;
                            examinationDetail.CreatedDate    = examination.CreatedDate;
                            examinationDetail.RescheduleDate = examination.RescheduleDate;
                            examinationDetail.EmployeeId     = examination.EmployeeId;
                            examinationDetail.EmployeeName   = trainee.name;
                            examinationDetail.SubjectId      = examination.SubjectId;
                            examinationDetail.Subjects       = examination.Subjects;

                            loadExamination.Add(examinationDetail);
                        }
                    }
                }
            }
            else
            {
                examnations = Enumerable.Empty <Examination>();
                ModelState.AddModelError(string.Empty, "Server Error try after sometimes.");
            }
            return(Json(loadExamination));
        }
Пример #2
0
 public void Put(ExaminationVM subject)
 {
     service.Update(subject.ToEntity());
 }
Пример #3
0
        public ExaminationVM Post(ExaminationVM subject)
        {
            var rs = service.Add(subject.ToEntity());

            return(rs == null ? null : BaseVM <object> .ToModel <ExaminationVM>(rs));
        }