Beispiel #1
0
        public async Task <IActionResult> PutAppointment(string id, Appointment appointment)
        {
            if (id != appointment.AppointmentID)
            {
                return(BadRequest());
            }

            _context.Entry(appointment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppointmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <object> Handle(CreateRegistration request, CancellationToken cancellationToken)
        {
            var _Student = new Models.Entity.Student
            {
                Name       = request.Name,
                FatherName = request.FatherName,
                GenderId   = request.GenderID,
                Nid        = request.Nid,
                Email      = request.Email,
                Phone      = request.Phone
            };
            await eMSContext.AddAsync(_Student);

            await eMSContext.SaveChangesAsync();

            var _Registration = new Models.Entity.Registration {
                StudentId        = _Student.Id,
                TestId           = request.TestID,
                Toaken           = request.Token,
                AccessLevelId    = request.AccessLevelID,
                RegistrationDate = DateTime.Now,
                TokenExpireTime  = DateTime.Now.AddDays(1)
            };
            await eMSContext.AddAsync(_Registration);

            await eMSContext.SaveChangesAsync();

            return(_Registration);
        }
Beispiel #3
0
        public async Task <IActionResult> PutEmployee(int id, Employee employee)
        {
            if (id != employee.Id)
            {
                return(BadRequest());
            }

            _context.Entry(employee).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> PutBilling(int id, Billing billing)
        {
            if (id != billing.BillingID)
            {
                return(BadRequest());
            }

            _context.Entry(billing).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BillingExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <object> Handle(CreateQuestion request, CancellationToken cancellationToken)
        {
            var Question = new Models.Entity.Question
            {
                CategoryId     = request.CategoryID,
                QuestionTypeId = request.QuestionTypeID,
                Lebel          = request.Lebel,
                Point          = request.Point,
                IsActive       = request.isActive
            };
            await EMSContext.AddAsync(Question);

            await EMSContext.SaveChangesAsync(cancellationToken);

            var img = new Models.Entity.Photo
            {
                FileName = request.FileName,
                RecordId = Question.Id,
                Base64   = request.Base64
            };
            await EMSContext.AddAsync(img);

            await EMSContext.SaveChangesAsync(cancellationToken);

            IList <Choice> Choices = new List <Choice> {
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice1, Points = request.Choice1Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice2, Points = request.Choice2Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice3, Points = request.Choice3Score
                },
                new Choice {
                    QuestionId = Question.Id, Label = request.Choice4, Points = request.Choice4Score
                }
            };
            await EMSContext.AddRangeAsync(Choices);

            await EMSContext.SaveChangesAsync();



            //EMSContext.Model.en

            //await EMSContext.AddAsync(Choices);
            //await EMSContext.SaveChangesAsync(cancellationToken);
            return(new
            {
                Message = "New Question Type added."
            });
        }
        public async Task <IActionResult> Create([Bind("Id,CategoryId,QuestionTypeId,Lebel,Point,IsActive")] Question question)
        {
            if (ModelState.IsValid)
            {
                _context.Add(question);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["CategoryId"]     = new SelectList(_context.Category, "Id", "Id", question.CategoryId);
            ViewData["QuestionTypeId"] = new SelectList(_context.QuestionType, "Id", "Id", question.QuestionTypeId);
            return(View(question));
        }
Beispiel #7
0
        public async Task <bool> Create(User user)
        {
            UserDAO userDAO = new UserDAO
            {
                Id        = user.Id,
                IsAdmin   = user.IsAdmin,
                Username  = user.Username,
                Password  = user.Password,
                StudentId = user.StudentId,
            };

            context.User.Add(userDAO);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Create(RegisterExam form)
        {
            RegisterExamDAO formDAO = new RegisterExamDAO
            {
                Id                    = form.Id,
                Graduated             = form.Graduated,
                ClusterContestId      = form.ClusterContestId,
                RegisterPlaceOfExamId = form.RegisterPlaceOfExamId,
                Maths                 = form.Maths,
                Literature            = form.Literature,
                Languages             = form.Languages,
                NaturalSciences       = form.NaturalSciences,
                SocialSciences        = form.SocialSciences,
                Physics               = form.Physics,
                Chemistry             = form.Chemistry,
                Biology               = form.Biology,
                History               = form.History,
                Geography             = form.Geography,
                CivicEducation        = form.CivicEducation,

                ExceptLanguages       = form.ExceptLanguages,
                Mark                  = form.Mark,
                ReserveMaths          = form.ReserveMaths,
                ReserveLiterature     = form.ReserveLiterature,
                ReserveLanguages      = form.ReserveLanguages,
                ReservePhysics        = form.ReservePhysics,
                ReserveChemistry      = form.ReserveChemistry,
                ReserveBiology        = form.ReserveBiology,
                ReserveHistory        = form.ReserveHistory,
                ReserveGeography      = form.ReserveGeography,
                ReserveCivicEducation = form.ReserveCivicEducation,

                PriorityType = form.PriorityType,
                Area         = form.Area,
                Status       = form.Status,
                StudentId    = CurrentContext.StudentId,
            };

            context.RegisterExam.Add(formDAO);
            if (form.Aspirations.Any())
            {
                await BulkCreateAspirations(form);
            }
            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #9
0
        public async Task <ActionResult <Patient> > Register(Patient patient)
        {
            if (!String.IsNullOrEmpty(patient.HeadOfHouse))
            {
                var headOfHouse = _context.Patients.Find(patient.HeadOfHouse);
                if (headOfHouse != null)
                {
                    patient.AddressLine1 = headOfHouse.AddressLine1;
                    patient.AddressLine2 = headOfHouse.AddressLine2;
                    patient.City         = headOfHouse.City;
                    patient.Province     = headOfHouse.Province;
                    patient.PostalCode   = headOfHouse.PostalCode;
                    patient.PhoneNumber  = headOfHouse.PhoneNumber;

                    ModelState.MarkFieldValid("HeadOfHouse");
                }
                else
                {
                    ModelState.AddModelError("HeadOfHouse", $"can not find the Head of House {patient.HCN}");
                }
            }


            if (!ModelState.IsValid)
            {
                return(View(patient));
            }

            _context.Patients.Add(patient);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PatientExists(patient.HCN))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetPatient", new { id = patient.HCN }, patient));
        }
        public async Task <bool> Create(Student student)
        {
            StudentDAO studentDAO = new StudentDAO
            {
                Id             = student.Id,
                Address        = student.Address,
                Dob            = student.Dob,
                Gender         = student.Gender,
                EthnicId       = student.EthnicId,
                HighSchoolId   = student.HighSchoolId,
                Name           = student.Name,
                Email          = student.Email,
                Phone          = student.Phone,
                PlaceOfBirth   = student.PlaceOfBirth,
                TownId         = student.TownId,
                Identify       = student.Identify,
                Image          = student.Image,
                Biology        = student.Biology,
                Chemistry      = student.Chemistry,
                CivicEducation = student.CivicEducation,
                Geography      = student.Geography,
                History        = student.History,
                Languages      = student.Languages,
                Literature     = student.Literature,
                Maths          = student.Maths,
                Physics        = student.Physics,
                Status         = 0
            };

            context.Student.Add(studentDAO);
            await context.SaveChangesAsync();

            UserDAO userDAO = new UserDAO
            {
                Username  = student.User.Username,
                Password  = student.User.Password,
                IsAdmin   = student.User.IsAdmin,
                StudentId = studentDAO.Id
            };

            context.User.Add(userDAO);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task<bool> Create(Majors majors)
        {
            MajorsDAO majorsDAO = new MajorsDAO
            {
                Id = majors.Id,
                Code = majors.Code,
                Name = majors.Name
            };

            context.Majors.Add(majorsDAO);
            await context.SaveChangesAsync();
            return true;
        }
        public async Task <bool> Create(Province province)
        {
            ProvinceDAO provinceDAO = new ProvinceDAO
            {
                Id   = province.Id,
                Code = province.Code,
                Name = province.Name
            };

            context.Province.Add(provinceDAO);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <object> Handle(UpdateQuestion request, CancellationToken cancellationToken)
        {
            var _Question = EMSContext.Question.Where(x => x.Id == request.ID).FirstOrDefault();

            //TODO check null and validate
            _Question.Lebel      = request.Lebel;
            _Question.Point      = request.Point;
            _Question.IsActive   = request.IsActive;
            _Question.CategoryId = request.CategoryID;
            await EMSContext.SaveChangesAsync(cancellationToken);

            return(_Question);
            //throw new System.NotImplementedException();
        }
Beispiel #14
0
        public async Task <bool> Create(SubjectGroup subjectGroup)
        {
            SubjectGroupDAO subjectGroupDAO = new SubjectGroupDAO
            {
                Id   = subjectGroup.Id,
                Code = subjectGroup.Code,
                Name = subjectGroup.Name
            };

            context.SubjectGroup.Add(subjectGroupDAO);
            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #15
0
        public async Task <object> Handle(CreateTest request, CancellationToken cancellationToken)
        {
            var Test = new Models.Entity.Test {
                Name              = request.Name,
                Description       = request.Description,
                IsActive          = request.IsActive,
                DurationInMinutes = request.DurationInMinutes
            };
            await EMSContext.AddAsync(Test);

            await EMSContext.SaveChangesAsync(cancellationToken);

            return(Test);
        }
        public async Task <bool> Create(Town town)
        {
            TownDAO TownDAO = new TownDAO
            {
                Id         = town.Id,
                Code       = town.Code,
                Name       = town.Name,
                DistrictId = town.DistrictId,
            };

            context.Town.Add(TownDAO);
            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #17
0
        public async Task <Appointment> ScheduleAppointment(DateTime date, int slot, string patientID)
        {
            Appointment appointment = new Appointment
            {
                AppointmentID   = Guid.NewGuid().ToString(),
                AppointmentDate = date,
                AppointmentSlot = slot,
                Encounter       = false
            };

            Schedule schedule = new Schedule
            {
                ScheduleID    = Guid.NewGuid().ToString(),
                AppointmentID = appointment.AppointmentID,
                PatientID     = patientID
            };
            await _context.Appointments.AddAsync(appointment);

            await _context.Schedules.AddAsync(schedule);

            await _context.SaveChangesAsync();

            return(appointment);
        }
        public async Task <bool> Create(University_Majors university_Majors)
        {
            University_MajorsDAO university_MajorsDAO = new University_MajorsDAO
            {
                Id           = university_Majors.Id,
                MajorsId     = university_Majors.MajorsId,
                UniversityId = university_Majors.UniversityId,
                Year         = university_Majors.Year
            };

            context.University_Majors.Add(university_MajorsDAO);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <bool> Create(District district)
        {
            DistrictDAO DistrictDAO = new DistrictDAO
            {
                Id         = district.Id,
                Code       = district.Code,
                Name       = district.Name,
                ProvinceId = district.ProvinceId
            };

            context.District.Add(DistrictDAO);
            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #20
0
        public async Task <bool> Create(University university)
        {
            UniversityDAO universityDAO = new UniversityDAO
            {
                Id      = university.Id,
                Code    = university.Code,
                Name    = university.Name,
                Address = university.Address,
                Website = university.Website
            };

            context.University.Add(universityDAO);
            await context.SaveChangesAsync();

            return(true);
        }
        public async Task <object> Handle(CreateQuestionTypeCommand request, CancellationToken cancellationToken)
        {
            var questionType = new Models.Entity.QuestionType
            {
                Name = request.Name
            };

            await eMSContext.AddAsync(questionType);

            await eMSContext.SaveChangesAsync(cancellationToken);

            return(new
            {
                Message = "New Question Type added."
            });
        }
        public async Task <bool> Create(HighSchoolBO highSchool)
        {
            HighSchoolDAO HighSchoolDAO = new HighSchoolDAO
            {
                Id         = highSchool.Id,
                Code       = highSchool.Code,
                Name       = highSchool.Name,
                ProvinceId = highSchool.ProvinceId,
                Address    = highSchool.Address,
            };

            context.HighSchool.Add(HighSchoolDAO);
            await context.SaveChangesAsync();

            return(true);
        }
Beispiel #23
0
        public async Task <object> Handle(SavePhotoCommand request, CancellationToken cancellationToken)
        {
            var _photo = new Models.Entity.Photo
            {
                RecordId = request.RecordId,
                FileName = request.FileName,
                Path     = request.Path,
                Base64   = request.Base64 //,
                                          //File = request.File
            };
            await eMSContext.AddAsync(_photo);

            await eMSContext.SaveChangesAsync();

            return(_photo);
        }
Beispiel #24
0
        public async Task <bool> Create(University_Majors_SubjectGroup university_Majors_SubjectGroup)
        {
            University_Majors_SubjectGroupDAO university_Majors_SubjectGroupDAO = new University_Majors_SubjectGroupDAO
            {
                Id = university_Majors_SubjectGroup.Id,
                University_MajorsId = university_Majors_SubjectGroup.University_MajorsId,
                SubjectGroupId      = university_Majors_SubjectGroup.SubjectGroupId,
                Benchmark           = university_Majors_SubjectGroup.Benchmark,
                Quantity            = university_Majors_SubjectGroup.Quantity,
                Note = university_Majors_SubjectGroup.Note
            };

            await context.University_Majors_SubjectGroup.AddAsync(university_Majors_SubjectGroupDAO);

            await context.SaveChangesAsync();

            return(true);
        }