public async Task <ActionResult> PostStudent(StudentInsertDTO student) { UserAccount newAccount = new UserAccount(student.Username, student.Password, 3, student.AvatarUrl); int newAccountId = await _userAccountRepository.AddUserAccount(newAccount); if (newAccountId != 0) { Student newStudent = new Student() { UserAccountId = newAccountId, FirstName = student.FirstName, LastName = student.LastName, BirthDate = student.Birthdate, Description = student.Description, Email = student.Email, Phone = student.Phone, Points = 0 }; var edcId = await _studentRepository.AddStudent(newStudent); return(Ok()); } return(BadRequest()); }
public async Task <ActionResult> PostEducator(AdminInsertDTO admin) { try { UserAccount newAccount = new UserAccount(admin.Username, admin.Password, 1, admin.AvatarUrl); int newAccountId = await _userAccountRepository.AddUserAccount(newAccount); if (newAccountId != 0) { Administrator newAdmin = new Administrator(admin.FirstName, admin.LastName, admin.Email, admin.Phone, newAccountId); var admId = await _administratorRepository.AddAdmin(newAdmin); return(Ok()); } return(BadRequest()); } catch (Exception ex) { throw ex; } }
public async Task <ActionResult> PostEducator(EducatorInsertDTO educator) { try { UserAccount newAccount = new UserAccount(educator.Username, educator.Password, 2, educator.AvatarUrl); int newAccountId = await _userAccountRepository.AddUserAccount(newAccount); if (newAccountId != 0) { Educator newEducator = new Educator(educator.FirstName, educator.LastName, educator.Email, educator.Phone, newAccountId, educator.Title, educator.CourseFieldId); var edcId = await _educatorRepository.AddEducator(newEducator); return(Ok()); } return(BadRequest()); } catch (Exception ex) { throw ex; } }
public ActionResult <UserAccountDto> CreateUserAccount(Guid companyId, Guid userAccountId, UserAccountForCreationDto userAccount) { var userAccountEntity = _mapper.Map <Entities.UserAccount>(userAccount); userAccountEntity.CompanyId = companyId; userAccountEntity.Id = userAccountId; _userAccountRepository.AddUserAccount(userAccountEntity); _userAccountRepository.Save(); var userAccountToReturn = _mapper.Map <UserAccountDto>(userAccountEntity); var links = CreateLinksForUserAccount(companyId.ToString(), userAccountToReturn.Id.ToString(), null); var linkedResourceToReturn = userAccountToReturn.ShapeData(null) as IDictionary <string, object>; linkedResourceToReturn.Add("links", links); return(CreatedAtRoute("GetUserAccount", new { companyId, userAccountId = linkedResourceToReturn["Id"] }, linkedResourceToReturn)); }
public void AddUserAccount(UserAccount userAccount) { _userAccountRepository.AddUserAccount(userAccount); }
private void AddUserAccount(UserAccount userAccount) { _userAccountRepository.AddUserAccount(userAccount); }