Example #1
0
        public StudentEntity Create(StudentEntity StudentEntity)
        {
            Student student = StudentEntity.ToModel();

            IMSContext.Students.Add(student);
            IMSContext.SaveChanges();
            return(new StudentEntity(IMSContext.Students.Where(s => s.Id == student.Id).FirstOrDefault()));
        }
Example #2
0
        public StudentEntity Update(UserEntity UserEntity, Guid StudentId, StudentEntity StudentEntity)
        {
            Student student = IMSContext.Students.Where(s => s.Id == StudentId).FirstOrDefault();

            if (student == null)
            {
                throw new BadRequestException("User not found");
            }
            StudentEntity.ToModel(student);
            IMSContext.SaveChanges();
            return(new StudentEntity(student));
        }
Example #3
0
        public StudentEntity Create(UserEntity UserEntity, StudentEntity StudentEntity)
        {
            Student student = StudentEntity.ToModel();
            User    User    = new User();

            User.Id       = student.Id;
            User.Username = StudentEntity.Username;
            User.Password = "******";

            IMSContext.Users.Add(User);
            IMSContext.Students.Add(student);
            IMSContext.SaveChanges();
            // return new StudentEntity(IMSContext.Students.Where(s => s.Id == student.Id).FirstOrDefault());
            return(Get(UserEntity, student.Id));
        }