Exemple #1
0
        public async Task <IActionResult> Register([FromServices] IStudentAccountService studentAccountService, [FromServices] ITeacherAccountService teacherAccountService, string name, string surname, string email, string username, string password, int age, int gender, int accountType)
        {
            IAccount account = new Account
            {
                Password = password,
                UserName = username,
                Status   = (Status)accountType,
                User     = new User
                {
                    GenderType = (Gender)gender,
                    Age        = age,
                    Surname    = surname,
                    Mail       = email,
                    Name       = name,
                }
            };

            if (account.Status == Status.Student)
            {
                await studentAccountService.AddStudentAccountDbAsync(account.Map <IAccount, IStudentAccount>());
            }
            else
            {
                await teacherAccountService.AddTeacherAccountDbAsync(account.Map <IAccount, ITeacherAccount>());
            }

            return(RedirectToAction("Login"));
        }