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 async Task Create(TEntity entity)
        {
            await _dbContext.Set <TEntity>()
            .AddAsync(entity);

            await _dbContext.SaveChangesAsync();
        }
        public async Task <Measurement> Post(Measurement item)
        {
            try
            {
                var addedMeasurements = await _context.Measurements.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedMeasurements.Entity);
            }
            catch
            {
                return(new Measurement());
            }
        }
Esempio n. 4
0
        public async Task <Procedure> Post(Procedure item)
        {
            try
            {
                var addedProcedure = await _context.Procedures.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedProcedure.Entity);
            }
            catch
            {
                return(new Procedure());
            }
        }
Esempio n. 5
0
        public async Task <Treatment> Post(Treatment item)
        {
            try
            {
                var addedTreatment = await _context.Treatments.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedTreatment.Entity);
            }
            catch
            {
                return(new Treatment());
            }
        }
Esempio n. 6
0
        public async Task <Patient> Post(Patient item)
        {
            try
            {
                var addedPatient = await _context.Patients.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedPatient.Entity);
            }
            catch
            {
                return(new Patient());
            }
        }
Esempio n. 7
0
        public async Task <Doctor> Post(Doctor item)
        {
            try
            {
                var addedDoctor = await _context.Doctors.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedDoctor.Entity);
            }
            catch
            {
                return(new Doctor());
            }
        }
Esempio n. 8
0
        public async Task <Nurse> Post(Nurse item)
        {
            try
            {
                var addedNurse = await _context.Nurses.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedNurse.Entity);
            }
            catch
            {
                return(new Nurse());
            }
        }
        public async Task <User> Post(User user)
        {
            try
            {
                var addedUser = await _context.Users.AddAsync(user);

                await _context.SaveChangesAsync();

                return(addedUser.Entity);
            }
            catch
            {
                return(new User());
            }
        }
Esempio n. 10
0
        public async Task <Account> Post(Account account)
        {
            try
            {
                var addedAccount = await _context.Accounts.AddAsync(account);

                await _context.SaveChangesAsync();

                return(addedAccount.Entity);
            }
            catch
            {
                return(new Account());
            }
        }
        public async Task <Medicine> Post(Medicine item)
        {
            try
            {
                var addedMedicine = await _context.Medicines.AddAsync(item);

                await _context.SaveChangesAsync();

                return(addedMedicine.Entity);
            }
            catch
            {
                return(new Medicine());
            }
        }
        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());
            }
        }