public void CourseComplete(string name, uint hours, Grade grade, string semester)
        {
            CourseResult cr = new CourseResult(name, hours, grade, semester);

            CourseHistory.Append(cr);
            NotifyPropertyChanged("GPA");
        }
        public async Task <Course> Post(Course course)
        {
            try
            {
                var lastCourse = await _context.Courses.LastAsync();

                //reference ID indexer
                course.TransactionId = lastCourse.TransactionId + 1;

                var addedCourse = await _context.Courses.AddAsync(course);

                await _context.SaveChangesAsync();

                //every instance of a course added there's also a course history created
                var newCourseHist = new CourseHistory {
                    CourseId = addedCourse.Entity.CourseId
                };
                var lastCourseHistory = await _context.CourseHistories.LastAsync();

                //auto indexer
                newCourseHist.CourseHistoryNumber = lastCourseHistory.CourseHistoryNumber + 1;
                await _context.CourseHistories.AddAsync(newCourseHist);

                await _context.SaveChangesAsync();

                return(addedCourse.Entity);
            }
            catch
            {
                return(new Course());
            }
        }
        public ActionResult Create(CourseHistory coursehistory)
        {
            if (ModelState.IsValid)
            {
                context.CourseHistories.Add(coursehistory);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.PossibleCourses = context.Courses;
            return View(coursehistory);
        }
 public CourseHistory Put(CourseHistory courseHistory)
 {
     try
     {
         var content = _context.CourseHistories.Update(courseHistory);
         _context.SaveChanges();
         return(content.Entity);
     }
     catch
     {
         return(new CourseHistory());
     }
 }
示例#5
0
 public ActionResult Put([FromBody] CourseHistory courseHistory)
 {
     if (courseHistory == null)
     {
         throw new NoNullAllowedException("No courseHistory found");
     }
     try
     {
         var entity = _couseHistoryService.Put(courseHistory);
         return(Ok(entity));
     }
     catch
     {
         throw new NullReferenceException("courseHistory Update Failed");
     }
 }
示例#6
0
        public async Task <ActionResult> Post([FromBody] CourseHistory courseHistory)
        {
            if (courseHistory == null)
            {
                throw new NullReferenceException("Course History not found");
            }
            try
            {
                var entity = await _couseHistoryService.Post(courseHistory);

                return(Ok(entity));
            }
            catch
            {
                throw new NullReferenceException("Course History Registration Failed");
            }
        }
        public async Task <CourseHistory> Post(CourseHistory courseHistory)
        {
            try
            {
                var patient = await _context.Patients.FirstOrDefaultAsync(c => c.PatientNumber == courseHistory.UserAccountNumber);

                courseHistory.PatientId = patient.PatientId;

                //var doctor = await _context.Doctors.FirstOrDefaultAsync(c =>c.DoctorNumber == courseHistory.UserAccountNumber)

                //auto indexer
                var addedCourseHistory = _context.CourseHistories.Update(courseHistory);
                await _context.SaveChangesAsync();

                return(addedCourseHistory.Entity);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new CourseHistory());
            }
        }
示例#8
0
 public async Task <IList <CourseHistoryData> > GetAllHistory(string id)
 {
     return(CourseHistory.ToJavaScriptCourseHistory(await _eventStoreRepository.All(id)));
 }
        public async Task <CourseHistory> AddCourseHistory(CourseHistory courseHistory)
        {
            var data = await _requestProvider.PostAsync("coursehistory/", courseHistory);

            return(data);
        }
        public async Task <CourseHistory> UpdateCourseHistory2(CourseHistory courseHistory)
        {
            var data = await _requestProvider.PutAsync2("coursehistory/", courseHistory);

            return(data);
        }
 public ActionResult Edit(CourseHistory coursehistory)
 {
     if (ModelState.IsValid)
     {
         context.Entry(coursehistory).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.PossibleCourses = context.Courses;
     return View(coursehistory);
 }