public IEnumerable <AsisstentResponse> GetAllAssistents() { List <AsisstentResponse> assistents = new List <AsisstentResponse>(); Create(); using (connection) { var command = new SqlCommand("SELECT * FROM [dbo].[User] INNER JOIN [dbo].[Assistent] ON AssistentId = [dbo].[Assistent].Id; ", connection); using (var reader = command.ExecuteReader()) { while (reader.Read()) { AsisstentResponse assistent = new AsisstentResponse(); assistent.Id = Guid.Parse(reader["Id"].ToString()); assistent.AsisstentId = Guid.Parse(reader["AssistentId"].ToString()); assistent.FirstName = reader["FirstName"].ToString(); assistent.LastName = reader["LastName"].ToString(); assistent.Username = reader["Username"].ToString(); assistent.Email = reader["Email"].ToString(); assistent.AreaOfStudy = reader["AreaOfStudy"].ToString(); assistent.Department = reader["Department"].ToString(); assistent.University = reader["University"].ToString(); assistents.Add(assistent); } } Close(); } return(assistents); }
public AsisstentResponse GetById(Guid Id) { AsisstentResponse assistent = new AsisstentResponse(); Create(); using (connection) { var command = new SqlCommand("SELECT * FROM [dbo].[User] INNER JOIN [dbo].[Assistent] ON AssistentId = [dbo].[Assistent].Id where [dbo].[User].Id=@Id", connection); command.Parameters.Add("@Id", SqlDbType.UniqueIdentifier); command.Parameters["@Id"].Value = Id; using (var reader = command.ExecuteReader()) { while (reader.Read()) { assistent.Id = Guid.Parse(reader["Id"].ToString()); assistent.AsisstentId = Guid.Parse(reader["AssistentId"].ToString()); assistent.FirstName = reader["FirstName"].ToString(); assistent.LastName = reader["LastName"].ToString(); assistent.Username = reader["Username"].ToString(); assistent.Email = reader["Email"].ToString(); assistent.AreaOfStudy = reader["AreaOfStudy"].ToString(); assistent.Department = reader["Department"].ToString(); assistent.University = reader["University"].ToString(); } } Close(); } return(assistent); }
public AsisstentResponse Create(AssistentCreateRequest request) { Guid ID = _assistentDao.InsertAssistent(request); var response = new AsisstentResponse(_userService.Create(request, ID), ID, request.University, request.Department, request.AreaOfStudy); return(response); }
public AsisstentResponse Update(Guid Id, AssistentUpdateRequest request) { AsisstentResponse user = _assistentDao.GetById(Id); if (!string.IsNullOrWhiteSpace(request.Department)) { user.Department = request.Department; } if (!string.IsNullOrWhiteSpace(request.University)) { user.University = request.University; } if (!string.IsNullOrWhiteSpace(request.AreaOfStudy)) { user.AreaOfStudy = request.AreaOfStudy; } Guid ID = _assistentDao.UpdateAssistent(Id, _mapper.Map <AssistentUpdateRequest>(user)); var response = new AsisstentResponse(_userService.UpdateUser(Id, request), ID, request.University, request.Department, request.AreaOfStudy); return(response); }